Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sho sho is offline
external usenet poster
 
Posts: 2
Default Command Button Code to copy data

I have a spreadsheet where I would like to click a button
and it extracts certain information into a different sheet.

e.g. on Sheet 1 I would like to click a command button
that copies information from cells A1, C1, D1 & E1 and
places this in Sheet 2 cells E5, E7, E8 and E9

Can anyone help with the code to achieve this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Command Button Code to copy data

Sheet("Sheet2").Range("E5").Value = Sheet("Sheet1").Range("A1").Value
etc,etc
Mike F
"sho" wrote in message
...
I have a spreadsheet where I would like to click a button
and it extracts certain information into a different sheet.

e.g. on Sheet 1 I would like to click a command button
that copies information from cells A1, C1, D1 & E1 and
places this in Sheet 2 cells E5, E7, E8 and E9

Can anyone help with the code to achieve this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
sho sho is offline
external usenet poster
 
Posts: 2
Default Command Button Code to copy data

Mike,

Thanks for the reply unfortunately this won't work as I
will have more than 1 command button picking up different
cells on sheet 1 (e.g it may be cells A1, C1, D1 & E1 but
next time it may be A6, B6, C6, E6) it will always
populate the same fields on sheet 2 though (cells E5, E7,
E8, E9)

That was why I was looking to do was place a command
button at the end of each row in Sheet 1 so that when I
wish to copy that particuar row, I can press the button at
the end to copy the relevant row to the correct cells in
sheet 2

Hope this makes sense!


-----Original Message-----
Sheet("Sheet2").Range("E5").Value = Sheet("Sheet1").Range

("A1").Value
etc,etc
Mike F
"sho" wrote in

message
...
I have a spreadsheet where I would like to click a

button
and it extracts certain information into a different

sheet.

e.g. on Sheet 1 I would like to click a command button
that copies information from cells A1, C1, D1 & E1 and
places this in Sheet 2 cells E5, E7, E8 and E9

Can anyone help with the code to achieve this?



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Command Button Code to copy data

Put a button from the Forms toolbar on each row.

then assign each button to this one macro:

Option Explicit
Sub testme()

Dim myRow As Long

myRow = ActiveSheet.Buttons(Application.Caller).TopLeftCel l.Row

With ActiveSheet
Worksheets("Sheet2").Range("E5").Value = .Cells(myRow, "A").Value
Worksheets("Sheet2").Range("E7").Value = .Cells(myRow, "C").Value
'etc
End With

End Sub

====
An alternative. Put a forms button in Row 1 and make row 1 always visible--
with A1 visible, select B1, window|freeze panes

Then tell your user to select the row first and click the button. Use the
activecell's row to determine the row to copy.

Option Explicit
Sub testme2()

Dim myRow As Long

myRow = Activecell.row

With ActiveSheet
Worksheets("Sheet2").Range("E5").Value = .Cells(myRow, "A").Value
Worksheets("Sheet2").Range("E7").Value = .Cells(myRow, "C").Value
'etc
End With

End Sub


sho wrote:

Mike,

Thanks for the reply unfortunately this won't work as I
will have more than 1 command button picking up different
cells on sheet 1 (e.g it may be cells A1, C1, D1 & E1 but
next time it may be A6, B6, C6, E6) it will always
populate the same fields on sheet 2 though (cells E5, E7,
E8, E9)

That was why I was looking to do was place a command
button at the end of each row in Sheet 1 so that when I
wish to copy that particuar row, I can press the button at
the end to copy the relevant row to the correct cells in
sheet 2

Hope this makes sense!

-----Original Message-----
Sheet("Sheet2").Range("E5").Value = Sheet("Sheet1").Range

("A1").Value
etc,etc
Mike F
"sho" wrote in

message
...
I have a spreadsheet where I would like to click a

button
and it extracts certain information into a different

sheet.

e.g. on Sheet 1 I would like to click a command button
that copies information from cells A1, C1, D1 & E1 and
places this in Sheet 2 cells E5, E7, E8 and E9

Can anyone help with the code to achieve this?



.


--

Dave Peterson

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
command button code dummy Excel Discussion (Misc queries) 2 December 1st 09 02:57 PM
Code for my Command Button to automatically copy and insert a new tommy Excel Discussion (Misc queries) 0 January 28th 09 12:22 AM
VBA code behind command button [email protected] Excel Worksheet Functions 1 March 22nd 06 08:13 PM
Command Button VBA code Dave Peterson Excel Discussion (Misc queries) 2 January 25th 05 11:28 PM
Create Command Button from Code Bruce B[_2_] Excel Programming 0 July 14th 03 02:01 PM


All times are GMT +1. The time now is 08:00 AM.

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

About Us

"It's about Microsoft Excel"