Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi! I am writing a macro where I want to select a range. the first cell I
want to have in the selection is A1 but the last cell is Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select. how shall I write it? pls help! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
i = Cells(Cells.Rows.Count, "A").End(xlUp).Row Range("a1:A" & i).Select Mike "Arne Hegefors" wrote: Hi! I am writing a macro where I want to select a range. the first cell I want to have in the selection is A1 but the last cell is Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select. how shall I write it? pls help! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks. but that does not work for me since A1 is not a fixed cell just an
example. I tried writing: Range("a1" & Range("a1").Offset(i, 9)).Select but that did not select the whole area but just the two cells. please please can someone help me! "Mike H" skrev: Try this i = Cells(Cells.Rows.Count, "A").End(xlUp).Row Range("a1:A" & i).Select Mike "Arne Hegefors" wrote: Hi! I am writing a macro where I want to select a range. the first cell I want to have in the selection is A1 but the last cell is Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select. how shall I write it? pls help! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How is the first cell in the range determined
The first populated cell ? Try this p = Range("A1").End(xlDown).Row i = Cells(Cells.Rows.Count, "A").End(xlUp).Row Range("a" & p & ":A" & i).Select Or in a loop? Try this For x = 1 To 5 topcell = Range("A1").Offset(x).Row bottomcell = Cells(Cells.Rows.Count, "A").End(xlUp).Row Range("A" & topcell & ":A" & bottomcell).Select Next Mike "Arne Hegefors" wrote: thanks. but that does not work for me since A1 is not a fixed cell just an example. I tried writing: Range("a1" & Range("a1").Offset(i, 9)).Select but that did not select the whole area but just the two cells. please please can someone help me! "Mike H" skrev: Try this i = Cells(Cells.Rows.Count, "A").End(xlUp).Row Range("a1:A" & i).Select Mike "Arne Hegefors" wrote: Hi! I am writing a macro where I want to select a range. the first cell I want to have in the selection is A1 but the last cell is Range("a1").offset(i,0). Thus I cannot simple write Range("a1:A3").select. how shall I write it? pls help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can change range to select active rows instead of :=Range("S10 | Excel Discussion (Misc queries) | |||
macro to select range from active cell range name string | Excel Programming | |||
When entering data into a range of cells, select the entire range. | Excel Discussion (Misc queries) | |||
Compare a selected Range with a Named range and select cells that do not exist | Excel Programming | |||
Select Sheet then Select Range | Excel Programming |