Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select cell without copying it
I'm running this macro on word ( there's more to it, like defining oExcel and
so on) and it works fine. Dim SLOC As String SLOC = 103810 Dim counter As Integer For counter = 1 To 10000 Step 1 Selection = osheet.Range("D" & counter) ' Assumes SLOC is on column D If Selection = SLOC Then Call fillin End If Next counter The only problem is that when it finds something on column D it writes it to wherever the cursor is on the word document. This is not ideal. Is there any way around this, i.e. a way for the macro not to write the contents of the cell on the word document? TIA |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select cell without copying it
Hard to tell what you are doing, but it looks like you might be using
selection as a variable. If so, use a different variable. If you actually want to use the selection object, then preface it with the which app. instead of if selection = SLOC then use if oExcel.Selection = SLOC then also, this is probably the line where you write to word: Selection = osheet.Range("D" & counter) this probably should be osheet.Range("D" & counter).Select this could require Excel to have the focus. A better approach would be to avoid using select and selection. If osheet.Range("D" & counter).Value = SLOC then Call fillin end if -- Regards, Tom Ogilvy "A1pro" wrote: I'm running this macro on word ( there's more to it, like defining oExcel and so on) and it works fine. Dim SLOC As String SLOC = 103810 Dim counter As Integer For counter = 1 To 10000 Step 1 Selection = osheet.Range("D" & counter) ' Assumes SLOC is on column D If Selection = SLOC Then Call fillin End If Next counter The only problem is that when it finds something on column D it writes it to wherever the cursor is on the word document. This is not ideal. Is there any way around this, i.e. a way for the macro not to write the contents of the cell on the word document? TIA |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select cell without copying it
Thank You,
that works like a treat "Tom Ogilvy" wrote: Hard to tell what you are doing, but it looks like you might be using selection as a variable. If so, use a different variable. If you actually want to use the selection object, then preface it with the which app. instead of if selection = SLOC then use if oExcel.Selection = SLOC then also, this is probably the line where you write to word: Selection = osheet.Range("D" & counter) this probably should be osheet.Range("D" & counter).Select this could require Excel to have the focus. A better approach would be to avoid using select and selection. If osheet.Range("D" & counter).Value = SLOC then Call fillin end if -- Regards, Tom Ogilvy "A1pro" wrote: I'm running this macro on word ( there's more to it, like defining oExcel and so on) and it works fine. Dim SLOC As String SLOC = 103810 Dim counter As Integer For counter = 1 To 10000 Step 1 Selection = osheet.Range("D" & counter) ' Assumes SLOC is on column D If Selection = SLOC Then Call fillin End If Next counter The only problem is that when it finds something on column D it writes it to wherever the cursor is on the word document. This is not ideal. Is there any way around this, i.e. a way for the macro not to write the contents of the cell on the word document? TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying data from one workbook to another dependent on user select | Excel Discussion (Misc queries) | |||
Copying Select Repeating Cells in a Column | Excel Worksheet Functions | |||
can you select paste area before copying data | Excel Discussion (Misc queries) | |||
Copying select cells using VB | Excel Programming | |||
Copying and transfering select rows of data | Excel Programming |