View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Excel User Excel User is offline
external usenet poster
 
Posts: 18
Default how to select cells dynamically in excel macro?

Following is the sample macro. I want to get 2 worksheets, one beside the
other on a single new worksheet.

Sub Macro7()
Workbooks.Open Filename:="C:\Sujatha\Excel\Jan_sales.xls"
Application.Goto Reference:="JAN_SALES"
Selection.Copy
Windows("Book3.xls").Activate
ActiveSheet.Paste
Range("D1").Select
Application.CutCopyMode = False
Workbooks.Open Filename:="C:\Sujatha\Excel\Feb_sales.xls"
Application.Goto Reference:="FEB_SALES"
Selection.Copy
Windows("Book3.xls").Activate
ActiveSheet.Paste
End Sub

I have specified 'Range("D1").Select' explictly. Suppose I don't know where
the first range ends, I want the macro to go to the last +2 columns and then
make the next copy.

Thanks in advance