FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,368
- Office Version
- 365
- 2016
- Platform
- Windows
I have many different macros doing different actions within a spreadsheet by the user selecting the column first and the macro takes action on that column.
Example:
How can I use the application.InputBox as its own macro and then pass the iCol variable to the copy and/or delete procedures?
Example:
Code:
Sub CopyColumnOfData()
Dim r As Range: Set r = Application.InputBox("Click in the column to filter by", Type:=8)
Dim iCol As Long: iCol = r.Column
Columns(iCol).Copy Range("C1")
End Sub
Code:
Sub DeleteColumnOfData()
Dim r As Range: Set r = Application.InputBox("Click in the column to filter by", Type:=8)
Dim iCol As Long: iCol = r.Column
Columns(iCol).Delete
End Sub