Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default referencing the activecell

I'm stumped. I am wanting to copy information from cells in workbook A to
workbook B. I want to cycle through several rows but would rather not
bounce back and forth activating each WB. Is there a way to reference the
active cell in each workbook?

I tried setting a variable to the worksheet but it doesn't like it.

Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets(2)

Set wb2 = Workbooks.Open(strDir & strFile)
Set ws2 = wb.Worksheets(2)
ws1.Activecell = ws2.Activecell <---- This is the line I want to
use but this code doesn't work.

Thanks in advance.

Suzette


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default referencing the activecell

Activecell is not a property of the worksheet, it is a property of the
window, so you only have one.

You will need to keep tags of where you are in each worksheet.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Suzette" wrote in message
...
I'm stumped. I am wanting to copy information from cells in workbook A to
workbook B. I want to cycle through several rows but would rather not
bounce back and forth activating each WB. Is there a way to reference
the active cell in each workbook?

I tried setting a variable to the worksheet but it doesn't like it.

Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets(2)

Set wb2 = Workbooks.Open(strDir & strFile)
Set ws2 = wb.Worksheets(2)
ws1.Activecell = ws2.Activecell <---- This is the line I want to
use but this code doesn't work.

Thanks in advance.

Suzette



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default referencing the activecell

I'm stumped. I am wanting to copy information from cells in workbook
A to workbook B. I want to cycle through several rows but would
rather not bounce back and forth activating each WB. Is there a way
to reference the active cell in each workbook?

I tried setting a variable to the worksheet but it doesn't like it.

Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets(2)

Set wb2 = Workbooks.Open(strDir & strFile)
Set ws2 = wb.Worksheets(2)
ws1.Activecell = ws2.Activecell <---- This is the line I
want to use but this code doesn't work.

Thanks in advance.

Suzette


As well as what Bob has said, watch out for typos - e.g.:

Set ws2 = wb2.Worksheets(2) and not

Set ws2 = wb.Worksheets(2)

This is why it's best to set Option Explicit, as it'll pick up on
typos/errors like this.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default referencing the activecell

Thanks guys. I set it up to reference the cells in both workbooks and it
works perfectly.
"Bob Phillips" wrote in message
...
Activecell is not a property of the worksheet, it is a property of the
window, so you only have one.

You will need to keep tags of where you are in each worksheet.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Suzette" wrote in message
...
I'm stumped. I am wanting to copy information from cells in workbook A
to workbook B. I want to cycle through several rows but would rather not
bounce back and forth activating each WB. Is there a way to reference
the active cell in each workbook?

I tried setting a variable to the worksheet but it doesn't like it.

Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets(2)

Set wb2 = Workbooks.Open(strDir & strFile)
Set ws2 = wb.Worksheets(2)
ws1.Activecell = ws2.Activecell <---- This is the line I want
to use but this code doesn't work.

Thanks in advance.

Suzette





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default referencing the activecell

I must admit, I wondered whether that was a code typo, or a posting typo <g

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"IanKR" wrote in message
...
I'm stumped. I am wanting to copy information from cells in workbook
A to workbook B. I want to cycle through several rows but would
rather not bounce back and forth activating each WB. Is there a way
to reference the active cell in each workbook?

I tried setting a variable to the worksheet but it doesn't like it.

Set wb1 = ActiveWorkbook
Set ws1 = wb1.Worksheets(2)

Set wb2 = Workbooks.Open(strDir & strFile)
Set ws2 = wb.Worksheets(2)
ws1.Activecell = ws2.Activecell <---- This is the line I
want to use but this code doesn't work.

Thanks in advance.

Suzette


As well as what Bob has said, watch out for typos - e.g.:

Set ws2 = wb2.Worksheets(2) and not

Set ws2 = wb.Worksheets(2)

This is why it's best to set Option Explicit, as it'll pick up on
typos/errors like this.



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
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
referencing a different tab by referencing a list in the current s Kevin Excel Worksheet Functions 3 July 6th 07 07:57 PM
ActiveCell.FormulaR1C1 referencing a moving target. Bob Phillips Excel Programming 1 December 19th 06 04:33 PM
if activecell is value רוזנט Excel Programming 4 July 11th 06 08:19 PM
Referencing "current" row (not using ActiveCell.Row) Mark[_46_] Excel Programming 2 June 12th 04 02:21 PM


All times are GMT +1. The time now is 06:53 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"