I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
Both have some data
I want a command button on Sheet 1 with code that will copy amp; move some data
on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; 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
As always, post your macro for comments and suggestions.
--
Don Guillett
SalesAid Software
quot;RocketRodquot; gt; wrote in message
...
gt;I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
gt; Both have some data
gt; I want a command button on Sheet 1 with code that will copy amp; move some
gt; data
gt; on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; move some other
gt; data
gt; on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
gt; If I record a macro and run it it works perfectly
gt; If I copy that code into the Command Button code it has an error when it
gt; selects the data on Sheet 2
gt;
gt;
I should have - sorry
This stops with the Range(quot;B4quot;).Select line highlighted
Private Sub CommandButton1_Click()
'
' Macro1 Macro
' Macro recorded 27/02/2006 by Hughes
'
'
Sheets(quot;Sheet2quot;).Select
Range(quot;B4quot;).Select
Rows(quot;1:3quot;).Select
Selection.Copy
Range(quot;A10quot;).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets(quot;Sheet1quot;).Select
Range(quot;B4quot;).Select
Rows(quot;1:3quot;).Select
Application.CutCopyMode = False
Selection.Copy
Range(quot;A10quot;).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range(quot;B5quot;).Select
Application.CutCopyMode = False
End Sub
It stops in debug with the
quot;Don Guillettquot; wrote:
gt; As always, post your macro for comments and suggestions.
gt;
gt; --
gt; Don Guillett
gt; SalesAid Software
gt;
gt; quot;RocketRodquot; gt; wrote in message
gt; ...
gt; gt;I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
gt; gt; Both have some data
gt; gt; I want a command button on Sheet 1 with code that will copy amp; move some
gt; gt; data
gt; gt; on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; move some other
gt; gt; data
gt; gt; on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
gt; gt; If I record a macro and run it it works perfectly
gt; gt; If I copy that code into the Command Button code it has an error when it
gt; gt; selects the data on Sheet 2
gt; gt;
gt; gt;
gt;
gt;
gt;
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(quot;sheet1quot;).Rows(quot;18:20quot;).Value = _
Sheets(quot;sheet1quot;).Rows(quot;8:10quot;).Value
Sheets(quot;sheet2quot;).Rows(quot;18:20quot;).Value = _
Sheets(quot;sheet2quot;).Rows(quot;8:10quot;).Value
End Sub
--
Don Guillett
SalesAid Software
quot;RocketRodquot; gt; wrote in message
...
gt; I should have - sorry
gt; This stops with the Range(quot;B4quot;).Select line highlighted
gt;
gt; Private Sub CommandButton1_Click()
gt; '
gt; ' Macro1 Macro
gt; ' Macro recorded 27/02/2006 by Hughes
gt; '
gt;
gt; '
gt;
gt; Sheets(quot;Sheet2quot;).Select
gt; Range(quot;B4quot;).Select
gt; Rows(quot;1:3quot;).Select
gt; Selection.Copy
gt; Range(quot;A10quot;).Select
gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt; SkipBlanks _
gt; :=False, Transpose:=False
gt; Sheets(quot;Sheet1quot;).Select
gt; Range(quot;B4quot;).Select
gt; Rows(quot;1:3quot;).Select
gt; Application.CutCopyMode = False
gt; Selection.Copy
gt; Range(quot;A10quot;).Select
gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt; SkipBlanks _
gt; :=False, Transpose:=False
gt; Range(quot;B5quot;).Select
gt; Application.CutCopyMode = False
gt;
gt; End Sub
gt;
gt; It stops in debug with the
gt;
gt;
gt;
gt; quot;Don Guillettquot; wrote:
gt;
gt;gt; As always, post your macro for comments and suggestions.
gt;gt;
gt;gt; --
gt;gt; Don Guillett
gt;gt; SalesAid Software
gt;gt;
gt;gt; quot;RocketRodquot; gt; wrote in message
gt;gt; ...
gt;gt; gt;I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
gt;gt; gt; Both have some data
gt;gt; gt; I want a command button on Sheet 1 with code that will copy amp; move some
gt;gt; gt; data
gt;gt; gt; on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; move some other
gt;gt; gt; data
gt;gt; gt; on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
gt;gt; gt; If I record a macro and run it it works perfectly
gt;gt; gt; If I copy that code into the Command Button code it has an error when
gt;gt; gt; it
gt;gt; gt; selects the data on Sheet 2
gt;gt; gt;
gt;gt; gt;
gt;gt;
gt;gt;
gt;gt;
Oh, well done!!
Thank you very much!
quot;Don Guillettquot; wrote:
gt; try this idea. Modify to suit and repeat for the second sheet. The first
gt; line are the DESTINATION rows and the second is the SOURCE rows. Notice that
gt; they are the SAME SIZE. This can be done from anywhere in the workbook with
gt; NO selections necessary or desirable.
gt;
gt; Sub copyrowvalues()
gt; Sheets(quot;sheet1quot;).Rows(quot;18:20quot;).Value = _
gt; Sheets(quot;sheet1quot;).Rows(quot;8:10quot;).Value
gt;
gt; Sheets(quot;sheet2quot;).Rows(quot;18:20quot;).Value = _
gt; Sheets(quot;sheet2quot;).Rows(quot;8:10quot;).Value
gt; End Sub
gt; --
gt; Don Guillett
gt; SalesAid Software
gt;
gt; quot;RocketRodquot; gt; wrote in message
gt; ...
gt; gt; I should have - sorry
gt; gt; This stops with the Range(quot;B4quot;).Select line highlighted
gt; gt;
gt; gt; Private Sub CommandButton1_Click()
gt; gt; '
gt; gt; ' Macro1 Macro
gt; gt; ' Macro recorded 27/02/2006 by Hughes
gt; gt; '
gt; gt;
gt; gt; '
gt; gt;
gt; gt; Sheets(quot;Sheet2quot;).Select
gt; gt; Range(quot;B4quot;).Select
gt; gt; Rows(quot;1:3quot;).Select
gt; gt; Selection.Copy
gt; gt; Range(quot;A10quot;).Select
gt; gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt; gt; SkipBlanks _
gt; gt; :=False, Transpose:=False
gt; gt; Sheets(quot;Sheet1quot;).Select
gt; gt; Range(quot;B4quot;).Select
gt; gt; Rows(quot;1:3quot;).Select
gt; gt; Application.CutCopyMode = False
gt; gt; Selection.Copy
gt; gt; Range(quot;A10quot;).Select
gt; gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt; gt; SkipBlanks _
gt; gt; :=False, Transpose:=False
gt; gt; Range(quot;B5quot;).Select
gt; gt; Application.CutCopyMode = False
gt; gt;
gt; gt; End Sub
gt; gt;
gt; gt; It stops in debug with the
gt; gt;
gt; gt;
gt; gt;
gt; gt; quot;Don Guillettquot; wrote:
gt; gt;
gt; gt;gt; As always, post your macro for comments and suggestions.
gt; gt;gt;
gt; gt;gt; --
gt; gt;gt; Don Guillett
gt; gt;gt; SalesAid Software
gt; gt;gt;
gt; gt;gt; quot;RocketRodquot; gt; wrote in message
gt; gt;gt; ...
gt; gt;gt; gt;I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
gt; gt;gt; gt; Both have some data
gt; gt;gt; gt; I want a command button on Sheet 1 with code that will copy amp; move some
gt; gt;gt; gt; data
gt; gt;gt; gt; on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; move some other
gt; gt;gt; gt; data
gt; gt;gt; gt; on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
gt; gt;gt; gt; If I record a macro and run it it works perfectly
gt; gt;gt; gt; If I copy that code into the Command Button code it has an error when
gt; gt;gt; gt; it
gt; gt;gt; gt; selects the data on Sheet 2
gt; gt;gt; gt;
gt; gt;gt; gt;
gt; gt;gt;
gt; gt;gt;
gt; gt;gt;
gt;
gt;
gt;
glad to help
--
Don Guillett
SalesAid Software
quot;RocketRodquot; gt; wrote in message
news
gt; Oh, well done!!
gt; Thank you very much!
gt;
gt; quot;Don Guillettquot; wrote:
gt;
gt;gt; try this idea. Modify to suit and repeat for the second sheet. The first
gt;gt; line are the DESTINATION rows and the second is the SOURCE rows. Notice
gt;gt; that
gt;gt; they are the SAME SIZE. This can be done from anywhere in the workbook
gt;gt; with
gt;gt; NO selections necessary or desirable.
gt;gt;
gt;gt; Sub copyrowvalues()
gt;gt; Sheets(quot;sheet1quot;).Rows(quot;18:20quot;).Value = _
gt;gt; Sheets(quot;sheet1quot;).Rows(quot;8:10quot;).Value
gt;gt;
gt;gt; Sheets(quot;sheet2quot;).Rows(quot;18:20quot;).Value = _
gt;gt; Sheets(quot;sheet2quot;).Rows(quot;8:10quot;).Value
gt;gt; End Sub
gt;gt; --
gt;gt; Don Guillett
gt;gt; SalesAid Software
gt;gt;
gt;gt; quot;RocketRodquot; gt; wrote in message
gt;gt; ...
gt;gt; gt; I should have - sorry
gt;gt; gt; This stops with the Range(quot;B4quot;).Select line highlighted
gt;gt; gt;
gt;gt; gt; Private Sub CommandButton1_Click()
gt;gt; gt; '
gt;gt; gt; ' Macro1 Macro
gt;gt; gt; ' Macro recorded 27/02/2006 by Hughes
gt;gt; gt; '
gt;gt; gt;
gt;gt; gt; '
gt;gt; gt;
gt;gt; gt; Sheets(quot;Sheet2quot;).Select
gt;gt; gt; Range(quot;B4quot;).Select
gt;gt; gt; Rows(quot;1:3quot;).Select
gt;gt; gt; Selection.Copy
gt;gt; gt; Range(quot;A10quot;).Select
gt;gt; gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt;gt; gt; SkipBlanks _
gt;gt; gt; :=False, Transpose:=False
gt;gt; gt; Sheets(quot;Sheet1quot;).Select
gt;gt; gt; Range(quot;B4quot;).Select
gt;gt; gt; Rows(quot;1:3quot;).Select
gt;gt; gt; Application.CutCopyMode = False
gt;gt; gt; Selection.Copy
gt;gt; gt; Range(quot;A10quot;).Select
gt;gt; gt; Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
gt;gt; gt; SkipBlanks _
gt;gt; gt; :=False, Transpose:=False
gt;gt; gt; Range(quot;B5quot;).Select
gt;gt; gt; Application.CutCopyMode = False
gt;gt; gt;
gt;gt; gt; End Sub
gt;gt; gt;
gt;gt; gt; It stops in debug with the
gt;gt; gt;
gt;gt; gt;
gt;gt; gt;
gt;gt; gt; quot;Don Guillettquot; wrote:
gt;gt; gt;
gt;gt; gt;gt; As always, post your macro for comments and suggestions.
gt;gt; gt;gt;
gt;gt; gt;gt; --
gt;gt; gt;gt; Don Guillett
gt;gt; gt;gt; SalesAid Software
gt;gt; gt;gt;
gt;gt; gt;gt; quot;RocketRodquot; gt; wrote in message
gt;gt; gt;gt; ...
gt;gt; gt;gt; gt;I have a spreadsheet with quot;Sheet 1quot; and quot;Sheet 2quot;
gt;gt; gt;gt; gt; Both have some data
gt;gt; gt;gt; gt; I want a command button on Sheet 1 with code that will copy amp; move
gt;gt; gt;gt; gt; some
gt;gt; gt;gt; gt; data
gt;gt; gt;gt; gt; on Sheet 1 elsewhere on Sheet 1, then on Sheet 2 copy amp; move some
gt;gt; gt;gt; gt; other
gt;gt; gt;gt; gt; data
gt;gt; gt;gt; gt; on Sheet 2 elsewhere on Sheet 2 then return active cell to Sheet 1
gt;gt; gt;gt; gt; If I record a macro and run it it works perfectly
gt;gt; gt;gt; gt; If I copy that code into the Command Button code it has an error
gt;gt; gt;gt; gt; when
gt;gt; gt;gt; gt; it
gt;gt; gt;gt; gt; selects the data on Sheet 2
gt;gt; gt;gt; gt;
gt;gt; gt;gt; gt;
gt;gt; gt;gt;
gt;gt; gt;gt;
gt;gt; gt;gt;
gt;gt;
gt;gt;
gt;gt;
- Aug 14 Mon 2006 20:08
Want macro to select amp; copy cells from a different worksheet
close
全站熱搜
留言列表
發表留言