lgperformanceanalyst
New Member
- Joined
- Feb 15, 2013
- Messages
- 8
Hi All,
I have tried to use other posts but due to inexperience was not successful.
I am new to macros, but have managed to run the 2 subs below successfully:
Sub Delete_Empty_Columns()
first = Selection.Column
last = Selection.Columns(Selection.Columns.Count).Column
For i = last To first Step -1
If WorksheetFunction.CountBlank(ActiveSheet.Columns(i)) = 1048576 Then
Columns(i).Delete
End If
Next i
End Sub
Sub SelectData()
'
' SelectData Macro
'
'
Range("A4:EB10").Select
End Sub
I have managed to get them both running by clicking the button using the code below:
Private Sub CommandButton2_Click()
Call SelectData
Call Delete_Empty_Columns
End Sub
What I am trying to achieve is run the above macro on selected sheets within my workbook with the click of a button.
Any help would be great, I am new to macros so apologize if I am using the wrong terminology.
Thanks in advance for any help.
I have tried to use other posts but due to inexperience was not successful.
I am new to macros, but have managed to run the 2 subs below successfully:
Sub Delete_Empty_Columns()
first = Selection.Column
last = Selection.Columns(Selection.Columns.Count).Column
For i = last To first Step -1
If WorksheetFunction.CountBlank(ActiveSheet.Columns(i)) = 1048576 Then
Columns(i).Delete
End If
Next i
End Sub
Sub SelectData()
'
' SelectData Macro
'
'
Range("A4:EB10").Select
End Sub
I have managed to get them both running by clicking the button using the code below:
Private Sub CommandButton2_Click()
Call SelectData
Call Delete_Empty_Columns
End Sub
What I am trying to achieve is run the above macro on selected sheets within my workbook with the click of a button.
Any help would be great, I am new to macros so apologize if I am using the wrong terminology.
Thanks in advance for any help.