Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
RocketRod
 
Posts: n/a
Default Want macro to select & copy cells from a different worksheet

I have a spreadsheet with "Sheet 1" and "Sheet 2"
Both have some data
I want a command button on Sheet 1 with code that will copy & move some data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy & move some other data
on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
If I record a macro and run it it works perfectly
If I copy that code into the Command Button code it has an error when it
selects the data on Sheet 2


  #3   Report Post  
Posted to microsoft.public.excel.misc
RocketRod
 
Posts: n/a
Default Want macro to select & copy cells from a different worksheet

I should have - sorry
This stops with the Range("B4").Select line highlighted

Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 27/02/2006 by Hughes
'

'

Sheets("Sheet2").Select
Range("B4").Select
Rows("1:3").Select
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Range("B4").Select
Rows("1:3").Select
Application.CutCopyMode = False
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("B5").Select
Application.CutCopyMode = False

End Sub

It stops in debug with the



"Don Guillett" wrote:

As always, post your macro for comments and suggestions.

--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I have a spreadsheet with "Sheet 1" and "Sheet 2"
Both have some data
I want a command button on Sheet 1 with code that will copy & move some
data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy & move some other
data
on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
If I record a macro and run it it works perfectly
If I copy that code into the Command Button code it has an error when it
selects the data on Sheet 2





  #4   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett
 
Posts: n/a
Default Want macro to select & copy cells from a different worksheet

try this idea. Modify to suit and repeat for the second sheet. The first
line are the DESTINATION rows and the second is the SOURCE rows. Notice that
they are the SAME SIZE. This can be done from anywhere in the workbook with
NO selections necessary or desirable.

Sub copyrowvalues()
Sheets("sheet1").Rows("18:20").Value = _
Sheets("sheet1").Rows("8:10").Value

Sheets("sheet2").Rows("18:20").Value = _
Sheets("sheet2").Rows("8:10").Value
End Sub
--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I should have - sorry
This stops with the Range("B4").Select line highlighted

Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 27/02/2006 by Hughes
'

'

Sheets("Sheet2").Select
Range("B4").Select
Rows("1:3").Select
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Range("B4").Select
Rows("1:3").Select
Application.CutCopyMode = False
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("B5").Select
Application.CutCopyMode = False

End Sub

It stops in debug with the



"Don Guillett" wrote:

As always, post your macro for comments and suggestions.

--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I have a spreadsheet with "Sheet 1" and "Sheet 2"
Both have some data
I want a command button on Sheet 1 with code that will copy & move some
data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy & move some other
data
on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
If I record a macro and run it it works perfectly
If I copy that code into the Command Button code it has an error when
it
selects the data on Sheet 2







  #5   Report Post  
Posted to microsoft.public.excel.misc
RocketRod
 
Posts: n/a
Default Want macro to select & copy cells from a different worksheet

Oh, well done!!
Thank you very much!

"Don Guillett" wrote:

try this idea. Modify to suit and repeat for the second sheet. The first
line are the DESTINATION rows and the second is the SOURCE rows. Notice that
they are the SAME SIZE. This can be done from anywhere in the workbook with
NO selections necessary or desirable.

Sub copyrowvalues()
Sheets("sheet1").Rows("18:20").Value = _
Sheets("sheet1").Rows("8:10").Value

Sheets("sheet2").Rows("18:20").Value = _
Sheets("sheet2").Rows("8:10").Value
End Sub
--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I should have - sorry
This stops with the Range("B4").Select line highlighted

Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 27/02/2006 by Hughes
'

'

Sheets("Sheet2").Select
Range("B4").Select
Rows("1:3").Select
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Range("B4").Select
Rows("1:3").Select
Application.CutCopyMode = False
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("B5").Select
Application.CutCopyMode = False

End Sub

It stops in debug with the



"Don Guillett" wrote:

As always, post your macro for comments and suggestions.

--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I have a spreadsheet with "Sheet 1" and "Sheet 2"
Both have some data
I want a command button on Sheet 1 with code that will copy & move some
data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy & move some other
data
on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
If I record a macro and run it it works perfectly
If I copy that code into the Command Button code it has an error when
it
selects the data on Sheet 2










  #6   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett
 
Posts: n/a
Default Want macro to select & copy cells from a different worksheet

glad to help

--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
Oh, well done!!
Thank you very much!

"Don Guillett" wrote:

try this idea. Modify to suit and repeat for the second sheet. The first
line are the DESTINATION rows and the second is the SOURCE rows. Notice
that
they are the SAME SIZE. This can be done from anywhere in the workbook
with
NO selections necessary or desirable.

Sub copyrowvalues()
Sheets("sheet1").Rows("18:20").Value = _
Sheets("sheet1").Rows("8:10").Value

Sheets("sheet2").Rows("18:20").Value = _
Sheets("sheet2").Rows("8:10").Value
End Sub
--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I should have - sorry
This stops with the Range("B4").Select line highlighted

Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 27/02/2006 by Hughes
'

'

Sheets("Sheet2").Select
Range("B4").Select
Rows("1:3").Select
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet1").Select
Range("B4").Select
Rows("1:3").Select
Application.CutCopyMode = False
Selection.Copy
Range("A10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("B5").Select
Application.CutCopyMode = False

End Sub

It stops in debug with the



"Don Guillett" wrote:

As always, post your macro for comments and suggestions.

--
Don Guillett
SalesAid Software

"RocketRod" wrote in message
...
I have a spreadsheet with "Sheet 1" and "Sheet 2"
Both have some data
I want a command button on Sheet 1 with code that will copy & move
some
data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy & move some
other
data
on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
If I record a macro and run it it works perfectly
If I copy that code into the Command Button code it has an error
when
it
selects the data on Sheet 2










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
Need macro to copy a list of named cells between worksheets John Excel Worksheet Functions 3 January 8th 06 11:33 PM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
copy formatted (red font) cells from one worksheet to another Garrett Excel Discussion (Misc queries) 1 September 6th 05 08:02 AM
How to copy subtotalled cells to a new worksheet (in a macro), wi. LJB Excel Discussion (Misc queries) 2 June 23rd 05 02:00 AM
select worksheet to run macro Hidaya Excel Discussion (Misc queries) 5 December 1st 04 11:54 PM


All times are GMT +1. The time now is 12:56 PM.

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"