DIM help


Posted by mike k on June 18, 2001 10:14 AM

i am having trouble with the DIM function HOW DO I MAKE IT SO THAT MIKE CAN BE USED MORE THAN ONCE. SO IF "MIKE" CHANGES, it will still work. something like DIM MIKE(##?). thakns!. He is my code.

Private Sub CommandButton6_Click()
Dim mike
Range("BI1").Select
mike = ActiveCell.Formula
Range("B3").Select
Do Until ActiveCell.Formula = ""
If ActiveCell.Formula = mike Then
Selection.EntireRow.Copy
Range("a2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("B4").Select
Do Until ActiveCell.Formula = ""
If ActiveCell.Formula = mike Then
Selection.EntireRow.Select
Selection.Delete Shift:=xlUp
Application.CutCopyMode = False
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
MsgBox "data not found", vbOKOnly
End Sub



Posted by Vincent on June 19, 2001 8:18 AM

Try starting your macro that way...

Option explicit
Dim mike

sub yourmacro()
Dim mike
your code
end sub

If you Dim your variable at the beginning, you can use it in many subs.