VBA Sum(VLOOKUP)

FGaxha

Board Regular
Joined
Jan 10, 2023
Messages
227
Office Version
  1. 365
Platform
  1. Windows
I have a macro to lookup between tow table.
How to I summarize Employee Table1 to Employee Table.

Code as below:

Sub ADDCLM()
On Error Resume Next
Dim Dept_Row As Long
Dim Dept_Clm As Long
Table1 = Sheet1.Range("A3:A13") ' Employee_ID Column from Employee table
Table2 = Sheet1.Range("H3:I13") ' Range of Employee Table 1
Dept_Row = Sheet1.Range("E3").Row ' Change E3 with the cell from where you need to start populating the Department
Dept_Clm = Sheet1.Range("E3").Column
For Each cl In Table1
Sheet1.Cells(Dept_Row, Dept_Clm) = Application.WorksheetFunction.VLookup(cl, Table2, 2, False)
Dept_Row = Dept_Row + 1
Next cl
MsgBox "Done"
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Begin by explaining what "summarize" means to you. Better yet, post an example of what you mean:

Book1
ABCDEFGH
1
2Employee Table1ResultsEmployee Table1
3algeria?miaotse
4handelian?annelism
5pinkroot?hillside
6chou?tchi
7lupis?silex
8retaught?languish
9undark?alids
10rolando?betowered
11gannet?mintweed
12diplonema?clunked
13eugenols?overslur
Sheet6

using this free tool .

Also, you have declared variables Dept_Row and Dept_Clm
VBA Code:
Dim Dept_Row As Long
Dim Dept_Clm As Long
Why haven't you done the same thing for variables Table1, Table2, and cl?

One other thing, please try to use 'code tags' to format the code as I have done above

How to Post Your VBA Code

as it makes the code easier to read
 
Upvote 0
Sorry,

I want to summarize I3: I35 to to E3:E12.
Table1 is multiactivity.
Table2 is Lookup and Static.
Thanks again.
1681061147981.png
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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