Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to come up with a macro, but i'm having some
trouble. I have 3 columns in sheet "ChopList" and 3 columns in sheet "CALC4". I need the macro to look at columns F, H, and J on sheet "ChopList" and find the row in which the cell values are the same in columns B,C, and D on sheet "CALC4" and copy the value of the last populated cell of that row to Column L of sheet "ChopList" in the row with the same values. Pretty difficult for me to explain, if you need more info let me know. Thanks very much in advance for any input. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this:
Sub Test() Dim wks1 As Worksheet, wks2 As Worksheet Dim rng1 As Range, rng2 As Range Dim c1 As Range, c2 As Range, c3 As Range Dim rw As Long, col As Long Dim txt1 As String, txt2 As String Set wks1 = Sheets("ChopList") Set wks2 = Sheets("Calc4") rw = wks1.Cells(Rows.Count, 6).End(xlUp).Row With wks1 Set rng1 = Range(.Cells(1, 6), .Cells(rw, 6)) End With With wks2 Set rng2 = Range(.Cells(1, 2), .Cells(rw, 2)) End With Application.ScreenUpdating = False For Each c1 In rng1 For Each c2 In rng2 txt1 = Trim(c1) & Trim(c1(1, 3)) & Trim(c1(1, 5)) txt2 = Trim(c2) & Trim(c2(1, 2)) & Trim(c2(1, 3)) If txt1 = txt2 Then col = wks2.Cells(c2.Row, 256).End(xlToLeft).Column Set c3 = wks2.Cells(c2.Row, col) c1(1, 7) = c3 End If Next c2 Next Application.ScreenUpdating = True End Sub Regards, Greg -----Original Message----- I'm trying to come up with a macro, but i'm having some trouble. I have 3 columns in sheet "ChopList" and 3 columns in sheet "CALC4". I need the macro to look at columns F, H, and J on sheet "ChopList" and find the row in which the cell values are the same in columns B,C, and D on sheet "CALC4" and copy the value of the last populated cell of that row to Column L of sheet "ChopList" in the row with the same values. Pretty difficult for me to explain, if you need more info let me know. Thanks very much in advance for any input. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Searching for values | Excel Discussion (Misc queries) | |||
Searching for a cell with specified values | Excel Discussion (Misc queries) | |||
Searching for cell values | Excel Discussion (Misc queries) | |||
searching for values and summing the corresponding values | Excel Worksheet Functions | |||
Searching values in VBA | Excel Programming |