BACK2BASIC
New member
- Joined
- Oct 14, 2013
- Messages
- 25
- Reaction score
- 0
- Points
- 0
Hello all.
Would someone be willing to help me refine my search and replace routine? The programming is getting beyond my capabilities. It has been working fine until the schedulers added a new column to the report. Please allow me to explain:
I have two excel spreadsheets which are essentially identical except for the comment field. Each week a new spreadsheet comes out (Sheet A). Employees are to update the comments on their jobs from the previous old spreadsheet (Sheet B). I have written a VB routine to do this by simply extracting the job number in sheet A and searching for the same job number in sheet B. I then go to the comment field in sheet B and paste it in the same respective spot in the new sheet A. Below is the code to do this
The problem I am having now is our scheduling department has added a new field to the job. So now I have to make sure two fields match. Can you please help to modify the underlined statement to search for two fields to match simultaneously. They must match so I can be sure the comment is the correct one.
Would someone be willing to help me refine my search and replace routine? The programming is getting beyond my capabilities. It has been working fine until the schedulers added a new column to the report. Please allow me to explain:
I have two excel spreadsheets which are essentially identical except for the comment field. Each week a new spreadsheet comes out (Sheet A). Employees are to update the comments on their jobs from the previous old spreadsheet (Sheet B). I have written a VB routine to do this by simply extracting the job number in sheet A and searching for the same job number in sheet B. I then go to the comment field in sheet B and paste it in the same respective spot in the new sheet A. Below is the code to do this
The problem I am having now is our scheduling department has added a new field to the job. So now I have to make sure two fields match. Can you please help to modify the underlined statement to search for two fields to match simultaneously. They must match so I can be sure the comment is the correct one.
Code:
Public Sub Process_billing_data()
Dim CG As String
Dim GCell As Range
Dim x, y, z As Integer
Dim Mypath$, Mycomment$
x = 1
TestER = False
Sheets("Report out").Activate
For i = 2 To 100
CG = Cells(x, 5) ' Get the Job number
Sheets("JL").Activate
[U] Set GCell = ActiveSheet.Cells.Find(CG)[/U]
If Not GCell Is Nothing Then
With GCell
On Error GoTo ErrorHandler
Mycomment$ = .Offset(0, 6).Value
End With
Sheets("Report out").Activate
With ThisWorkbook.ActiveSheet.Cells(x, 1)
.Offset(0, 6).Value = Mycomment$
End With
Else
MsgBox ("Loop Stopped")
Sheets("Report out").Activate
End If
x = x + 1
Next i
ActiveWorkbook.Close SaveChanges:=True
ErrorHandler:
TestER = True
Resume Next
End Sub
Last edited: