S
sup191
I'm having trouble trying to figure out how to pass information to
subroutine. I'm hoping to cut down on a little code for cleaniness
but mostly to learn more about how to use VB in Excel. I have fou
columns that automatically have certain characters stripped out o
them. As of now, I'm calling the subs using:
If Not (Intersect(Target, Range("F:F")) Is Nothing) Then
Application.EnableEvents = False
NARemovalF
End If
And the sub looks like:
Sub NARemovalF()
Dim lLastRow As Long
Dim Sh1 As Worksheet, rng As Range
Set Sh1 = ThisWorkbook.Worksheets("Form")
lLastRow = Sh1.Cells(Rows.Count, "F").End(xlUp).Row
Set rng = Sh1.Range("F2", "F2" & lLastRow)
rng.Replace _
What:="N/A", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="n/a", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="NA", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="na", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
Set Sh1 = Nothing
Set rng = Nothing
End Sub
I have the same sub copied three other times for columns J, L, and N.
I know there has to be an easy way to pass the column letter to the su
so it will replace the "F" and "F2" information with the other colum
letters. How do I pass the correct info and use that info to replac
the cell ranges?
I know I've been posting tons of questions lately, but everybody ha
been very helpful and I'm learning so much from these forums. Thank
in advance!
subroutine. I'm hoping to cut down on a little code for cleaniness
but mostly to learn more about how to use VB in Excel. I have fou
columns that automatically have certain characters stripped out o
them. As of now, I'm calling the subs using:
If Not (Intersect(Target, Range("F:F")) Is Nothing) Then
Application.EnableEvents = False
NARemovalF
End If
And the sub looks like:
Sub NARemovalF()
Dim lLastRow As Long
Dim Sh1 As Worksheet, rng As Range
Set Sh1 = ThisWorkbook.Worksheets("Form")
lLastRow = Sh1.Cells(Rows.Count, "F").End(xlUp).Row
Set rng = Sh1.Range("F2", "F2" & lLastRow)
rng.Replace _
What:="N/A", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="n/a", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="NA", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
rng.Replace _
What:="na", Replacement:="", _
searchorder:=xlByRows, MatchCase:=True
Set Sh1 = Nothing
Set rng = Nothing
End Sub
I have the same sub copied three other times for columns J, L, and N.
I know there has to be an easy way to pass the column letter to the su
so it will replace the "F" and "F2" information with the other colum
letters. How do I pass the correct info and use that info to replac
the cell ranges?
I know I've been posting tons of questions lately, but everybody ha
been very helpful and I'm learning so much from these forums. Thank
in advance!
