Find and Replace with Excel VBA
Posted on 2003-02-20
I am reading in data from a csv file into a worksheet, the file is composed of name, and a number of tests, however some people have never attended a test therefore there is a blank there, I need a way of finding and replacing the blanks and replacing them with a value AB. How would I go about doing this? with the following section of code:
' Find_Replace Macro
' Macro recorded 20/02/2003 by Natalie Vance
Cells.Replace What:="lyndsay", Replacement:="ab", LookAt:=xlPart, _
However, I am reading the data from the csv file into a worksheet using the following code:
Public Sub Open_Workbook(OpenName As String)
Dim oCSV As Workbook
Open OpenName For Input As #1
Set oCSV = Workbooks.Open(OpenName)
Set oCSV = Nothing
So I ideally I would like to be able to call the Find_Replace function within the open_workbook function. Is this possible? Would I need to make the Find_Replace function public?
I would appreciate any help or suggestions.
Thanks in advance,