View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Change Reference to Columns in a Macro

If I understand you correctly, this concept should work.

Lets say that the column identifier you want to change is on a worksheet
named Sheet1 and it is in cell A1. Then your code can do something like
either of these examples:

Dim myColumns As String
myColumns = ThisWorkbook.Worksheets("Sheet1").Range("A1")
'assuming that cell A1 contained B:C then you dould do this

'you must activate the proper sheet first
Worksheets("Sheet2").Activate
Columns(myColumns).Select

and that would select columns A:C on Sheet2

You could even write it without "myColumns" this way
Worksheets("Sheet2").Activate
ThisWorkbook.Worksheets("Sheet1").Range("A1")
Columns(ThisWorkbook.Worksheets("Sheet1").Range("A 1")).Select

Hope this helps you with your problem.

"Nastech" wrote:

hi, is there a way to modify the reference to columns,
to be from a different single cell, such as INDIRECT..
within a macro / script? Thanks

the type of lines I want to reference a

Range("A1").Value
Columns("B:C").Select
Range("D:E").Select

Intersect(Me.Range("F:G"),
With Me.Cells(.Row, "H")