K
K
Hi all, I have macro (see below) in my Sheet Module
MACRO ON (ActiveX Control) BUTTON
**********************************************
Private Sub CommandButton3_Click()
ActiveSheet.Select
ActiveSheet.Copy After:=Sheets(1)
Range("C21").Select
Range(Cells(21, 3), Cells(Cells(Rows.Count, "B").End(xlUp).Row,
"N")).ClearContents
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 33 Then
Range(Cells(StartRow, 1), Cells(33, 1)).EntireRow.Delete
End If
End Sub
The problem is that when I put this Macro in Sheet Module and put on
"Command Button (ActiveX Control)" (as shown above) it highlights line
"Range ("C21").Select" and don’t work but if I delete that line it
still don’t work. But for some reason when I put this code on normal
Module (as shown below) and set on "Button (From Control)" it works
perfect. i want to put this macro in Sheet Module and want to set it
on "Command Button (ActiveX Control)" and want it to work. Can any
friend have any idea what should i do or what am i doing wron. Any
help will be much appricated
MACRO ON (From Control) BUTTON
*********************************************
Sub AddSht ()
ActiveSheet.Select
ActiveSheet.Copy After:=Sheets(1)
Range("C21").Select
Range(Cells(21, 3), Cells(Cells(Rows.Count, "B").End(xlUp).Row,
"N")).ClearContents
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 33 Then
Range(Cells(StartRow, 1), Cells(33, 1)).EntireRow.Delete
End If
End Sub
MACRO ON (ActiveX Control) BUTTON
**********************************************
Private Sub CommandButton3_Click()
ActiveSheet.Select
ActiveSheet.Copy After:=Sheets(1)
Range("C21").Select
Range(Cells(21, 3), Cells(Cells(Rows.Count, "B").End(xlUp).Row,
"N")).ClearContents
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 33 Then
Range(Cells(StartRow, 1), Cells(33, 1)).EntireRow.Delete
End If
End Sub
The problem is that when I put this Macro in Sheet Module and put on
"Command Button (ActiveX Control)" (as shown above) it highlights line
"Range ("C21").Select" and don’t work but if I delete that line it
still don’t work. But for some reason when I put this code on normal
Module (as shown below) and set on "Button (From Control)" it works
perfect. i want to put this macro in Sheet Module and want to set it
on "Command Button (ActiveX Control)" and want it to work. Can any
friend have any idea what should i do or what am i doing wron. Any
help will be much appricated
MACRO ON (From Control) BUTTON
*********************************************
Sub AddSht ()
ActiveSheet.Select
ActiveSheet.Copy After:=Sheets(1)
Range("C21").Select
Range(Cells(21, 3), Cells(Cells(Rows.Count, "B").End(xlUp).Row,
"N")).ClearContents
Dim StartRow As Long
StartRow = Cells(Rows.Count, 2).End(xlUp).Row
If StartRow >= 33 Then
Range(Cells(StartRow, 1), Cells(33, 1)).EntireRow.Delete
End If
End Sub