PDA

View Full Version : Variable



oleg_v
05-26-2010, 09:22 PM
hi

how can i change the range in the row below into a variable

g = Sheets("sheet3").Range("B65536").End(xlUp).row

thanks

Bob Phillips
05-27-2010, 12:52 AM
With Worksheets("Sheet3")

g = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B1"),Resize(g)
End With

oleg_v
05-27-2010, 03:24 AM
With Worksheets("Sheet3")

g = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B1"),Resize(g)
End With


It writs me "syntax error"

what should i do?

Bob Phillips
05-27-2010, 03:26 AM
Sorry, should be



With Worksheets("Sheet3")

g = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B1").Resize(g)
End With

oleg_v
05-27-2010, 03:44 AM
Sorry, should be



With Worksheets("Sheet3")

g = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B1").Resize(g)
End With


how can i write this macro that instead of "B" will be 2 and instead of
"b1" will be (2 & 1)

Aussiebear
05-27-2010, 04:14 AM
Are you changing yet again the substance of a question because you didn't ask the correct question or supply the correct data at the initial post?

mdmackillop
05-27-2010, 04:32 AM
Check out the Cells notation eg

Set rng = Cells(2,1)