Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying data from one workbook to another dependent on user select sarahphonics Excel Discussion (Misc queries) 1 April 19th 10 04:37 PM
Copying Select Repeating Cells in a Column Shalebot Excel Worksheet Functions 2 August 10th 09 09:05 PM
can you select paste area before copying data Roz2459 Excel Discussion (Misc queries) 4 January 29th 09 02:22 PM
Copying select cells using VB jagbabbra Excel Programming 1 March 16th 06 03:26 PM
Copying and transfering select rows of data Parmenion Excel Programming 2 April 26th 05 03:49 AM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"