B
briannyam
Dear All,
I am very new to VBA.
I wish to write two loops that
1. runs across the row ("7:7") to search for "N"
2. if there are nothing all the way down hundreds of rows below a column with "N", then hide or delete the entire column
Here is somehting I have writen and I am out of resource to continue.
Would you be able to help me out
Set r = Range("7:7")
Rows("7:7").Select
For Each Cell In r
Selection.Find(What:="N", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, MatchByte:=False, SearchFormat:=False).Activate
'search for N
Application.Run "deletecolumn"
Next
End Sub
ActiveCell.Offset(6, 0).Select
Range(Selection, Selection.End(xlDown)).Select
For Each Cell.Value In Selection
If Cell.Value = "" Then
'some code that let the loop goes on
Else
ActiveCell.Columns.Delete
End If
Next
End Sub
I am very new to VBA.
I wish to write two loops that
1. runs across the row ("7:7") to search for "N"
2. if there are nothing all the way down hundreds of rows below a column with "N", then hide or delete the entire column
Here is somehting I have writen and I am out of resource to continue.
Would you be able to help me out
Set r = Range("7:7")
Rows("7:7").Select
For Each Cell In r
Selection.Find(What:="N", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, MatchByte:=False, SearchFormat:=False).Activate
'search for N
Application.Run "deletecolumn"
Next
End Sub
ActiveCell.Offset(6, 0).Select
Range(Selection, Selection.End(xlDown)).Select
For Each Cell.Value In Selection
If Cell.Value = "" Then
'some code that let the loop goes on
Else
ActiveCell.Columns.Delete
End If
Next
End Sub