Excel VBA - Search And Replace Cell data

A

asmenut

I have a userform that allows the user to Add/Replace data to a spreadsheet.
Upon pressing the update button, the form updates the sheet, then opens a log
(separate workbook/sheet) in order to search 3 different columns in order to
match the cells (I have concantenated these cells together (and added an "A"
if column 3 is not "0") to form a log number (i.e. E28609, I28702A2). If the
cells match the Log number then I want to go to that row (offset to colum 7
and 8) and replace the data.

While I can update the existing form, I am having difficulty developing the
code to search and replace data in the Log. Any help would be greatly
appreciated.

'Open the EO Maintenence Log
Workbooks.Open Filename:="C:\Documents and Settings\John\My Documents\excel
shit\New_EO\Engineering Maintenence Log.xls"
'Sheets("EO_LOG").Activate

Dim r As Long
Dim Irow As Long
Dim RegInit As String
Dim Col1 As Range
Dim Col2 As Range
Dim Col3 As Range

Irow = Sheet1.UsedRange.Row + _
Sheet1.UsedRange.Rows.Count
For r = 1 To Irow
Set Col1 = ActiveSheet.Range("A:A")
Set Col2 = ActiveSheet.Range("B:B")
Set Col3 = ActiveSheet.Range("C:C")
If Cells(r, Col1).value = Left(EOTemp, 1) And _
Cells(r, Col2).Value = Mid(EOTemp, 2, 5) Then
ReqInit = Initials(ComboP_Engineer)
Cells(r, 7) = ReqInit
ReqInit = Initials(ComboP_Manager)
Cells(r, 8) = ReqInit
End If
Next r
End Sub

(Note: As I am in the "development" stage, I have not added
the criteria for column 3).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top