Comparing and updating sheets.
Hi sanju,
I started my old computer with Excel 2003.
I copied the code from my message and dit not get an error.
I modified the code to your last request with dynamic rows
When you copy the code into Excel VBE be sure to combine any red line
with the line above it.
Option Explicit
Dim shtSource As Worksheet
Dim lngLastS As Long
Sub Caller()
Set shtSource = Worksheets("Activity")
lngLastS = shtSource.Cells(shtSource.Rows.Count, 4).End(xlUp).Row
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
nehaAll "IP_MPLS"
nehaAll "BB"
nehaAll "DGE"
nehaAll "IPLC VCIPLC"
nehaAll "Voice"
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Set shtSource = Nothing
End Sub
Sub nehaAll(strTarget As String)
Dim shtTarget As Worksheet
Dim lngLoopT As Long
Dim lngLoopS As Long
Dim lngLastT As Long
Set shtTarget = Worksheets(strTarget)
lngLastT = shtTarget.Cells(shtTarget.Rows.Count, 1).End(xlUp).Row
For lngLoopS = 2 To lngLastS
For lngLoopT = 3 To lngLastT
Sheets("Activity").Cells(lngLoopS, 4).Select
If shtSource.Cells(lngLoopS, 4).Value =
shtTarget.Cells(lngLoopT, 1).Value Then
shtTarget.Cells(lngLoopT, 32).Value =
shtSource.Cells(lngLoopS, 10).Value
shtTarget.Cells(lngLoopT, 21).Value =
shtSource.Cells(lngLoopS, 1).Value
shtTarget.Cells(lngLoopT, 22).Value =
shtTarget.Cells(lngLoopT, 22).Value & _
". ;" & shtSource.Cells(lngLoopS, 2).Value & ";" &
_
shtSource.Cells(lngLoopS, 8).Value
End If
Next lngLoopT
Next lngLoopS
Set shtTarget = Nothing
End Sub
HTH,
Wouter.
|