Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'd like to move a block of cells, say A1:B1 for simplicity to another
area (Say, C16:D16) with a button (macro). Say I do this multiple times though, instead of having A1:B1 overwrite the same cells, I'd want it to move to the next row down (C17:D17) and move the data there. Is this possible in an easy to program answer? I have VB programming experience but NO experience with Excel, and whenever I look at excel code, it's all gobblygook to me! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Kyle,
Try: '=============== Private Sub CommandButton1_Click() Dim rng As Range Dim sRng As Range Dim dRng As Range Set rng = Range("C16") Set sRng = Range("A1:B1") Set dRng = Cells(Rows.Count, "C").End(xlUp)(2) sRng.Copy Destination:=IIf(IsEmpty(rng), rng, dRng) End Sub '<<=============== --- Regards, Norman wrote in message oups.com... I'd like to move a block of cells, say A1:B1 for simplicity to another area (Say, C16:D16) with a button (macro). Say I do this multiple times though, instead of having A1:B1 overwrite the same cells, I'd want it to move to the next row down (C17:D17) and move the data there. Is this possible in an easy to program answer? I have VB programming experience but NO experience with Excel, and whenever I look at excel code, it's all gobblygook to me! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i used a different approach - using a named range to store the destination
cell address. this way makes no assumptipons as to what else might or might not be on the worksheet. also allows for easily moving 1 or multiple cells of data. - voodooJoe Private Sub CommandButton1_Click() 'you need to first name the original destination cell, it is 'joe' in this example 'also assumes the values you want to move are selected With ThisWorkbook.Names("joe") Set tmp = .RefersToRange.Offset(Selection.Rows.Count) Selection.Cut .RefersToRange .RefersTo = tmp End With Set tmp = Nothing End Sub "Norman Jones" wrote in message ... Hi Kyle, Try: '=============== Private Sub CommandButton1_Click() Dim rng As Range Dim sRng As Range Dim dRng As Range Set rng = Range("C16") Set sRng = Range("A1:B1") Set dRng = Cells(Rows.Count, "C").End(xlUp)(2) sRng.Copy Destination:=IIf(IsEmpty(rng), rng, dRng) End Sub '<<=============== --- Regards, Norman wrote in message oups.com... I'd like to move a block of cells, say A1:B1 for simplicity to another area (Say, C16:D16) with a button (macro). Say I do this multiple times though, instead of having A1:B1 overwrite the same cells, I'd want it to move to the next row down (C17:D17) and move the data there. Is this possible in an easy to program answer? I have VB programming experience but NO experience with Excel, and whenever I look at excel code, it's all gobblygook to me! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Moving data from one worksheet to another... | Excel Worksheet Functions | |||
Moving data from one worksheet to another | New Users to Excel | |||
Moving a button on worksheet | Excel Worksheet Functions | |||
Moving Data to Another Worksheet | Excel Discussion (Misc queries) | |||
Worksheet name as part of Data Source parameter | Excel Programming |