VBA - Vlookup

RoseChapman

New Member
Joined
Jun 12, 2018
Messages
40
Hi, could anyone help me, please?
I have to copy from the Test2 spreadsheet from column AG to AJ and from column AL to BB and paste them in test 1 spreadsheet. The table array in Test 2 is E:BB. The formula below copy all columns, but I do not need to paste all columns I just need the ones I've mentioned above. What shall I include in the formula to be able to get what I need? many thanks for your help.

Sub Test()


For i = 8 To 100
For j = 1 To 22


On Error Resume Next
Sheets("Test1").Cells(i, j + 5).Value = Application.WorksheetFunction.VLookup(Sheets("Test1").Cells(i, 1).Value, Sheets("Test2").Range("E:BB"), j + 28, False)


On Error GoTo 0


Next j
Next i




End Sub
 
You're welcome & thanks for the feedback

Oh sorry!, i have checked properly and it does not work, it is copying columns 55 and 56 and removing columns 28 and 29 and I need the information from columns 28 to 54, I don't know how to fix this, could you please help me?
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Can you please explain what you are trying to do?
 
Upvote 0
What I am trying to do is basically a vlookup copying information from one sheet to another sheet.
Sheet 1 contains the information I want to pass on to Sheet 2,
The Ref number in sheet 1 is in column E and the Ref number in sheet 2 is in column A.
I have to copy columns AG to BB from sheet 1 and paste them in columns G to AB in sheet 2 (except column K, this one shouldn't be updated with any information from Sheet 1, column k in sheet 2 has to be untouchable).
I hope you can help. Many thanks
 
Upvote 0
In that case how about making this change
Code:
      outarr(j, K) = inarr(i, K + [COLOR=#ff0000]26[/COLOR])
 
Upvote 0
This time works! it does the job! thank you very much MrExcel, you do great support!, thank you once more MrExcel
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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