Hi,
I am very much a beginner with excel, but wanting to add a button on my spreadsheet to add a column after a specific column.
The code I have put together is as follows:
Sub AddColumns()
Dim varUserInput As Variant
varUserInput = InputBox("Enter Column Letter where you want to add a column:", _
"What Column?")
If varUserInput = "" Then Exit Sub
MyRange = varUserInput
' Store the selected range in a variable.
Set MyRange = Selection
' Select the entire column.
Selection.EntireColumn.Select
' Insert Columns in all selected sheets.
Selection.Insert
' Reselect the previously selected cells.
MyRange.Select
End Sub
This does not work though.
I also want to add a button to bring up a box to ask me to delete a specific row and also one to delete a specific column so basically I will have 3 buttons.
I already have a button to add a specific row.
Thanks so much for your help in advance.
Sean
I am very much a beginner with excel, but wanting to add a button on my spreadsheet to add a column after a specific column.
The code I have put together is as follows:
Sub AddColumns()
Dim varUserInput As Variant
varUserInput = InputBox("Enter Column Letter where you want to add a column:", _
"What Column?")
If varUserInput = "" Then Exit Sub
MyRange = varUserInput
' Store the selected range in a variable.
Set MyRange = Selection
' Select the entire column.
Selection.EntireColumn.Select
' Insert Columns in all selected sheets.
Selection.Insert
' Reselect the previously selected cells.
MyRange.Select
End Sub
This does not work though.
I also want to add a button to bring up a box to ask me to delete a specific row and also one to delete a specific column so basically I will have 3 buttons.
I already have a button to add a specific row.
Thanks so much for your help in advance.
Sean