-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathUpdateQuery.vb
56 lines (44 loc) · 1.94 KB
/
UpdateQuery.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Sub LookUp()
Dim Sh As Worksheet
Dim DestSh As Worksheet
Dim last As Long
Dim CopyRange As Range
Dim CopyValue As String
'File name
'strSheet = "DataCenterPracticeNewMetricsDatasheet.xlsm"
'File Path
'strPath = "C:\Users\ctwellma\Desktop\"
Set Sh = ActiveWorkbook.Worksheets("Sheet2")
Set DestSh = ActiveWorkbook.Worksheets("Sheet1")
'Loop Through Rows to Remove Blanks and Format
last = Lastrow(Sh)
endofpage = LastCol(Sh)
Debug.Print endofpage
firstrow = Sh.UsedRange.Cells(1).Row
lrow = last + firstrow - 1
With Sh 'Sheet 2 Loop through Each Name on Sheet 2
MsgBox ("Outerloop" & Sh.Name)
.DisplayPageBreaks = False
For lrow = last To firstrow Step -1
'Get Value to Check Against/Look Up
last2 = Lastrow(DestSh)
firstrow2 = DestSh.UsedRange.Cells(1).Row
Lrow2 = last2 + firstrow2 - 1
MsgBox (.Cells(lrow, "A").Value & " " & Sh.Name)
With DestSh ' Try to match name from Sheet 2 with list in Sheet 1
MsgBox ("Innerloop" & DestSh.Name)
For Lrow2 = last2 To firstrow2 Step -1
'
'MsgBox (.Cells(Lrow2, "A").Value & " " & DestSh.Name)
If .Cells(lrow, "A").Value = .Cells(Lrow2, "A").Value Then
MsgBox ("found one" & .Cells(lrow, "A").Value)
' MsgBox ("Match Found" & "$A$" & Lrow & .Cells(Lrow, "A").Value & " " & Sh.Name & " = " & "$A$" & Lrow2 & .Cells(Lrow2, "A").Value & " " & DestSh.Name)
' '.Cells(Lrow2, "B").Value = "$A$" & lrow
' Else
' 'MsgBox ("no Match")
End If
Next
End With
Next
End With
End Sub