I have an existing macro that I use to format columns. I've been using this without problems. Now, I'm looking to learn how to use Option Explicit and I am running into a problem with defining my variable.
What should I be dim'ing Level as? I tried Dim Level As String but that didn't work. I'm trying to get a better understanding so any feedback would be appreciated.
Option Explicit Sub adviseformat() Dim Form As Worksheet Set Form = Sheets("Formatting") With Form Level = WorksheetFunction.Match("Level", .Rows("1:1"), 0) .Columns(Level).Delete .Columns("D:E").Delete .Range("U:U").Value = Range("E:E").Value .Columns("E").EntireColumn.Delete .Columns("F:I").Delete .Columns("I").Delete .Columns("L").Delete .Columns("M").Delete Form.Range("A:B").EntireColumn.Insert Form.Range("A1").Value = "Owner" Form.Range("B1").Value = "Comment" Form.Range("A1").Interior.Color = 65535 Form.Range("B1").Interior.Color = 65535 Form.Range("O1").Interior.Color = 65535 End With End Sub
Level = WorksheetFunction.Match("Level", .Rows("1:1"), 0)Double.