![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#6
|
|||
|
|||
|
As per the earlier comments,
Originally Posted by vjvj123: I am quite worried that the macro which I had written (recorded) earlier by myself did not work the way I wanted. The worry is mainly due to the fact that what seems working when I use the manual sequence of operations using keyboard/mouse (and even when recording the macro), doesn't work the same way when the recorded macro is run. That is, when I press the del key repeatedly in a table cell in the middle of some text, the letters to the left should not be deleted, but running the macro actually deletes the letters to the left also. I would be thankful if you can throw some light (and possible remedy), since I mainly rely on recording macros rather than writing scripts as I am not conversant with that. and your reply,... Since you haven't posted your own code, it's impossible to know for sure what the issue is.[/QUOTE] I hereby post my code (generated through recording macro). The text in the table cell under consideration as an example is NMR#Mass. Code:
Sub Macro16()
'
' Macro16 Macro
'
'
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "#"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
End Sub
Will look forward for any comments on why running macro deletes everything in the cell, whereas it is intended to delete text only to the right of # Thank you Last edited by macropod; 09-24-2018 at 03:52 PM. Reason: Added code tags & formatting |
| Tags |
| delete text toright, macro, table cell |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
cell alignment gets deleted when using backspace in a cell
|
saandahn | Word Tables | 4 | 01-08-2018 09:27 AM |
| How to delete unused cell remaining at end of a block of deleted data | SKEETER | Excel | 2 | 10-24-2017 07:06 AM |
| How can I delete spaces & lines in a table cell | mrayncrental | Word VBA | 3 | 10-20-2014 07:09 PM |
Delete table if cell has data
|
So New2 This | Word VBA | 1 | 05-06-2013 09:00 PM |
| How can I delete the content of a cell in column if the cell value is more than 1000? | Learner7 | Excel | 2 | 06-27-2011 05:44 AM |