Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I
fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? A B C 1 4 Select Copy 2 2 3 4 4 5 5 14 6 9 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Try this: LastRow = Range("A1").End(xlDown).Row Range("B1").Copy ActiveSheet.Paste Range("B2:B" & LastRow) or LastRow = Range("A1").End(xlDown).Row Range("B1").Copy Destination:= Range("B2:B" & LastRow) Regards, Per "Mathieu" skrev i meddelelsen ... Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? A B C 1 4 Select Copy 2 2 3 4 4 5 5 14 6 9 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, thanks, it's working partially to what I need. What if it's not always B1
but instead I want to have the ability to chose the cell I need by using this Range("A1").End(xlDown) or something like that. Thanks! -- Mathieu "Per Jessen" wrote: Hi Try this: LastRow = Range("A1").End(xlDown).Row Range("B1").Copy ActiveSheet.Paste Range("B2:B" & LastRow) or LastRow = Range("A1").End(xlDown).Row Range("B1").Copy Destination:= Range("B2:B" & LastRow) Regards, Per "Mathieu" skrev i meddelelsen ... Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? A B C 1 4 Select Copy 2 2 3 4 4 5 5 14 6 9 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi.
I made a few "trial and error" and I have modified the code a little bit. Do ou see any problem with this code? and can you briefly explain the "long" variable, what is i's use? Thanks a lot. Sub Test2() Dim lngRows As Long Dim SRng As Range lngRows = Range("A1").End(xlDown).Row - 2 Set SRng = Range("A1").End(xlToRight).Offset(2, 0).Resize(lngRows) SRng.Select 'just for testing End Sub -- Mathieu "Mathieu" wrote: Hi, thanks, it's working partially to what I need. What if it's not always B1 but instead I want to have the ability to chose the cell I need by using this Range("A1").End(xlDown) or something like that. Thanks! -- Mathieu "Per Jessen" wrote: Hi Try this: LastRow = Range("A1").End(xlDown).Row Range("B1").Copy ActiveSheet.Paste Range("B2:B" & LastRow) or LastRow = Range("A1").End(xlDown).Row Range("B1").Copy Destination:= Range("B2:B" & LastRow) Regards, Per "Mathieu" skrev i meddelelsen ... Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? A B C 1 4 Select Copy 2 2 3 4 4 5 5 14 6 9 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I don't see any problems with your code, but I don't know which cells you expect to be selected. "Long" is a 4-byte integer ranging in value from -2,147,483,648 to 2,147,483,647 "Integer" is a data type that holds integer variables stored as 2-byte whole numbers in the range -32,768 to 32,767 Regards, Per On 18 Nov., 22:48, Mathieu wrote: Hi. I made a few "trial and error" and I have modified the code a little bit. Do ou see any problem with this code? and can you briefly explain the "long" variable, what is i's use? Thanks a lot. Sub Test2() Dim lngRows * * * * As Long Dim SRng * * * * * *As Range * *lngRows = Range("A1").End(xlDown).Row - 2 * *Set SRng = Range("A1").End(xlToRight).Offset(2, 0).Resize(lngRows) * *SRng.Select * 'just for testing End Sub -- Mathieu "Mathieu" wrote: Hi, thanks, it's working partially to what I need. What if it's not always B1 but instead I want to have the ability to chose the cell I need by using this Range("A1").End(xlDown) or something like that. Thanks! -- Mathieu "PerJessen" wrote: Hi Try this: LastRow = Range("A1").End(xlDown).Row Range("B1").Copy ActiveSheet.Paste Range("B2:B" & LastRow) or LastRow = Range("A1").End(xlDown).Row Range("B1").Copy Destination:= Range("B2:B" & LastRow) Regards, Per "Mathieu" skrev i meddelelsen ... Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? * * * *A * * * * * * * *B * * * * * * * * * * *C 1 * * *4 * * * * * * *Select Copy 2 * * *2 3 * * *4 4 * * *5 5 * * 14 6 * * *9- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you!
-- Mathieu Bouffard "Per Jessen" wrote: Hi I don't see any problems with your code, but I don't know which cells you expect to be selected. "Long" is a 4-byte integer ranging in value from -2,147,483,648 to 2,147,483,647 "Integer" is a data type that holds integer variables stored as 2-byte whole numbers in the range -32,768 to 32,767 Regards, Per On 18 Nov., 22:48, Mathieu wrote: Hi. I made a few "trial and error" and I have modified the code a little bit. Do ou see any problem with this code? and can you briefly explain the "long" variable, what is i's use? Thanks a lot. Sub Test2() Dim lngRows As Long Dim SRng As Range lngRows = Range("A1").End(xlDown).Row - 2 Set SRng = Range("A1").End(xlToRight).Offset(2, 0).Resize(lngRows) SRng.Select 'just for testing End Sub -- Mathieu "Mathieu" wrote: Hi, thanks, it's working partially to what I need. What if it's not always B1 but instead I want to have the ability to chose the cell I need by using this Range("A1").End(xlDown) or something like that. Thanks! -- Mathieu "PerJessen" wrote: Hi Try this: LastRow = Range("A1").End(xlDown).Row Range("B1").Copy ActiveSheet.Paste Range("B2:B" & LastRow) or LastRow = Range("A1").End(xlDown).Row Range("B1").Copy Destination:= Range("B2:B" & LastRow) Regards, Per "Mathieu" skrev i meddelelsen ... Hi, I am trying to copy cell B1 and them select B2 to B6 by code. So far, I fail by using this. Selection.Resize(Range("A1").End(xlDown).Row).past e How can I code it? A B C 1 4 Select Copy 2 2 3 4 4 5 5 14 6 9- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Resize Problem | Excel Programming | |||
Problem transferring array data onto worksheet using Resize | Excel Programming | |||
having problem with resize | Excel Programming | |||
problem with resize property | Excel Programming | |||
Resize Range Problem | Excel Programming |