A
axwack
Folks,
The following codes looks through a selection and any time the macro
finds the value ("ticker") in the row, it selects that column and then
deletes it.
The following code gets me what I want but the issue is when there is
no value left in the selection, the macro errors saying there is no
Object defined.
I think I declared this incorrectly. Can anyone suggest and
alternative to this?
Sub deleteTickerColumn()
Dim wks As Worksheet
Dim Rng As Range
Set wks = Worksheets("Instructions")
Application.ScreenUpdating = False
With wks
For Each Rng In .Range("h5").CurrentRegion
.Cells.Find(What:="ticker", After:=ActiveCell,
LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If Rng Is Nothing Then
Exit Sub
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
End If
Next Rng
End With
Application.ScreenUpdating = True
End Sub
The following codes looks through a selection and any time the macro
finds the value ("ticker") in the row, it selects that column and then
deletes it.
The following code gets me what I want but the issue is when there is
no value left in the selection, the macro errors saying there is no
Object defined.
I think I declared this incorrectly. Can anyone suggest and
alternative to this?
Sub deleteTickerColumn()
Dim wks As Worksheet
Dim Rng As Range
Set wks = Worksheets("Instructions")
Application.ScreenUpdating = False
With wks
For Each Rng In .Range("h5").CurrentRegion
.Cells.Find(What:="ticker", After:=ActiveCell,
LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If Rng Is Nothing Then
Exit Sub
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
End If
Next Rng
End With
Application.ScreenUpdating = True
End Sub