falcon
07-08-2005, 05:04 PM
The code below copies and pastes data to and from different tabs in a Excel spreadsheet. The 2 tabs are "MASTER" & "ON_OFF" I dont if you can follow my weak attempt to write code but it always gets an error, if its not a IF, END or With error. Any help would be appreciated.
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = "False" Then
Sheets("ON_OFF").Select
With Range("M59").Select
Selection.Copy
Sheets("MASTER").Select
Range("K59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Range("H59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I59").Select
Application.CutCopyMode = False
Selection.Copy
Range("G59").Select
ActiveSheet.Paste
Range("I59").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("D59").Select
End With
Else
If ToggleButton1.Value = "True" Then
Sheets("MASTER").Select
With Range("G59").Select
Selection.Copy
Range("I59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G59").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("ON_OFF").Select
With Range("P59").Select
'--------- Selection.Copy
Sheets("MASTER").Select
Range("K59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H59").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("D59").Select
End If
End With
End Sub
In advance - Thanks for helping. :bow:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = "False" Then
Sheets("ON_OFF").Select
With Range("M59").Select
Selection.Copy
Sheets("MASTER").Select
Range("K59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.Copy
Range("H59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I59").Select
Application.CutCopyMode = False
Selection.Copy
Range("G59").Select
ActiveSheet.Paste
Range("I59").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("D59").Select
End With
Else
If ToggleButton1.Value = "True" Then
Sheets("MASTER").Select
With Range("G59").Select
Selection.Copy
Range("I59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("G59").Select
Application.CutCopyMode = False
Selection.ClearContents
Sheets("ON_OFF").Select
With Range("P59").Select
'--------- Selection.Copy
Sheets("MASTER").Select
Range("K59").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H59").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("D59").Select
End If
End With
End Sub
In advance - Thanks for helping. :bow: