macro help please
One way:
Option Explicit
Sub columnremove()
Dim myRng As Range
Select Case LCase(ActiveSheet.Name)
Case Is = LCase("Month One"), LCase("Month Two"), LCase("Month Three")
Set myRng = ActiveSheet.Rows(4)
'for rows that have 0's or blanks in column A
'set myRng = activesheet.range("a:a")
With myRng
.Replace What:=0, Replacement:="", LookAt:=xlWhole
On Error Resume Next
.Cells.SpecialCells(xlCellTypeBlanks).EntireColumn .Delete
On Error GoTo 0
End With
Case Else
MsgBox "Please activate the correct sheet first!"
End Select
End Sub
Ryk wrote:
I have a macro that I'd like to limit the pages it can work on.
Sub columnremove()
Dim myRng As Range
Set myRng = ActiveSheet.Rows(4)
'for rows that have 0's or blanks in column A
'set myRng = activesheet.range("a:a")
With myRng
.Replace What:=0, Replacement:="", LookAt:=xlWhole
On Error Resume Next
.Cells.SpecialCells(xlCellTypeBlanks).EntireColumn .Delete
On Error GoTo 0
End With
End Sub
If i click it, and I am on wrong page it can ruin alot of work, I have
only 3 pages it can work on, Month One, Month Two and Month Three.
Can this macro be made to "check" if its in one of those pages and not
fire, or give an error message if it is not?
Ryk
--
Dave Peterson
|