Good afternoon all.
I have the following code in a spreadsheet and on clicking a command button it simply saves the file using a cell reference for the filename. Selects an area, copies and pastes it using number values and formats. Then it deletes the command button. Could someone test this out as it used to work perfectly. Recently I added more columns to the right of E column but this should have no affect. But stepping through the code it was as it should until "Range("B3:C15").Select" where it proceeds to select B3:E15 and then copies and pastes that range.
Has anyone come across this before?
Many thanks
Nigel
Private Sub CommandButton1_Click()
'Dim Path As String
Dim filename As String
Path = "X:\Corporate Clients Excel\Weekly takings\"
filename = Range("G3")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsx", FileFormat:=51
Range("B3:C15").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Shapes("CommandButton1").Delete
End Sub
I have the following code in a spreadsheet and on clicking a command button it simply saves the file using a cell reference for the filename. Selects an area, copies and pastes it using number values and formats. Then it deletes the command button. Could someone test this out as it used to work perfectly. Recently I added more columns to the right of E column but this should have no affect. But stepping through the code it was as it should until "Range("B3:C15").Select" where it proceeds to select B3:E15 and then copies and pastes that range.
Has anyone come across this before?
Many thanks
Nigel
Private Sub CommandButton1_Click()
'Dim Path As String
Dim filename As String
Path = "X:\Corporate Clients Excel\Weekly takings\"
filename = Range("G3")
ActiveWorkbook.SaveAs filename:=Path & filename & ".xlsx", FileFormat:=51
Range("B3:C15").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Sheet1").Shapes("CommandButton1").Delete
End Sub