vlookup vba

leeb91

New Member
Joined
May 22, 2015
Messages
20
What I am having trouble with is a twist to regular Vlookup vba code. Here, I have a table from G2:H9 in Sheet1. All of the cells listed in Column G2:G9 has tranposed values (Header) as the ones in the first row of Sheet3. When I run a macro, a value in H2, which corresponds to G2 will be copied and pasted into every cell in Column D in Sheet3 from row 2.
So, Basically, I have H2,H3,H4, ... , H9 in which the value in each of these cell will be copy/pasted into the entire column D, AC, X,Y, AE, AF, AD, F respectively from row2~ to the last row with data in sheet2(Imported data)
I will use the following code to determine the last row the value has to be pasted to. I believe this code will look for the last used row with data in sheet2.
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Dim lastRow As Long
Dim rng As Range

Set rng = ThisWorkbook.Sheets(2).Cells

lastRow
= rng.Find(What:="*", After:=rng.Cells(1), Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row</code>Or I might even consider using this to find out the last row
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Dim sht As Worksheet
Dim LastRow As Long

Set sht = ThisWorkbook.Worksheets(2)

'Ctrl + Shift + End
LastRow
= sht.Cells(sht.Rows.Count, "A").End(xlUp).Row</code>Is this even possible? I would very much appreciate any help on this. Thanks in advance
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,203,027
Messages
6,053,120
Members
444,640
Latest member
Dramonzo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top