Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Moving data from one part of a worksheet to another with a button

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Moving data from one part of a worksheet to another with a button

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Moving data from one part of a worksheet to another with a button

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving data from one worksheet to another... Allen Excel Worksheet Functions 3 September 9th 08 10:52 PM
Moving data from one worksheet to another tjvols New Users to Excel 1 March 14th 08 04:27 AM
Moving a button on worksheet Jock Excel Worksheet Functions 5 November 2nd 07 03:50 PM
Moving Data to Another Worksheet Crimsann Excel Discussion (Misc queries) 3 September 7th 05 06:22 PM
Worksheet name as part of Data Source parameter [email protected] Excel Programming 2 June 2nd 05 08:34 PM


All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"