Good afternoon everyone,
I would like to set up a macro, I have some experience in visual basic, so I know the steps that I would take to create this macro, I just don't know how to search through a column or a row for a specific value, then to save only the value identifying only that column or that row.
I've worked out my steps, just need some help with the lines.
From worksheet #1, it will count how many columns are in a specific row.
Then starting from the first column, it will remember three fields. (A, B C and D). Using those variables, it will find what goes in line E from a table on a different worksheet.
Open the second worksheet (from a share server).
It will then need to search as follows...
1. Search through row 58 (specifically from A58 to BT58) and find a specific value to match to value A. (lets call it "X") we will need to remember only the column that "X" is in.
2. Match for "B". (B can either be yes or no)
3. if “Yes” then set the Column to A (A58), if “No” then the column to B (B58) having the value of “No” shifts the column with the data needed over one to the right.)
4. Search that column for the value to match for C. (Lets call these G, H, and I) and remember that row.
5. Search that same column for another value to match to D ( this will be a decimal number) and remember that row.
6. for the row with the G, H, or I (from line 4) search across that Row for another value (x, y or z) remember that column.
7. match the column from line 6 and the row for line 5 and go to that Cell. copy and paste the value of that cell to line E from the parent worksheet.
8. go to the next column and repeat the above steps until all columns have been filled in with value E.
I know it is all very confusing.
I wish I could upload the layout of the table, that would clear things up, but I’m at work and cannot.
The table is several tables in one.
Think of it like a plus sign, the bottom left will tell you what row will have your answer. The top left will refine that row down even more (for every four in the bottom left, the top left has one.) the top right gives you the column you need to be in for your answer. The answer block is the bottom right.
If your totally confused, then your in the right spot… cause that’s how it is.. (and this is why I would like to create a macro to help me find my answer, and to help me reduce mistakes. )
Here is what I have to begin with...
I would like for it to update as data changes from within the cells that fill in the fields A B C and D.. I don't know how to do that ether, so for now it will run from clicking a button.
Function TableLookup ()
On Error Resume Next
Workbooks("Test.xls").Activate
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For i = 2 To RowCount
Range("a" & i).Select
Aa = ActiveCell.Value
Bb = ActiveCell.Offset(0, 1).Value
Cc = ActiveCell.Offset(0, 2).Value
Dd = ActiveCell.Offset(0, 3).Value
Workbooks("Table0026.xls").Activate
'this is where I need help
'the value will be set to "Ee"
Workbooks("Test.xls").Activate
Range("a" & i).Select
ActiveCell.Offset(0, 4).Value = Ee
Next
End Function
Any help would be very much appreciated
Thank you all!!
Qazzart.
I would like to set up a macro, I have some experience in visual basic, so I know the steps that I would take to create this macro, I just don't know how to search through a column or a row for a specific value, then to save only the value identifying only that column or that row.
I've worked out my steps, just need some help with the lines.
From worksheet #1, it will count how many columns are in a specific row.
Then starting from the first column, it will remember three fields. (A, B C and D). Using those variables, it will find what goes in line E from a table on a different worksheet.
Open the second worksheet (from a share server).
It will then need to search as follows...
1. Search through row 58 (specifically from A58 to BT58) and find a specific value to match to value A. (lets call it "X") we will need to remember only the column that "X" is in.
2. Match for "B". (B can either be yes or no)
3. if “Yes” then set the Column to A (A58), if “No” then the column to B (B58) having the value of “No” shifts the column with the data needed over one to the right.)
4. Search that column for the value to match for C. (Lets call these G, H, and I) and remember that row.
5. Search that same column for another value to match to D ( this will be a decimal number) and remember that row.
6. for the row with the G, H, or I (from line 4) search across that Row for another value (x, y or z) remember that column.
7. match the column from line 6 and the row for line 5 and go to that Cell. copy and paste the value of that cell to line E from the parent worksheet.
8. go to the next column and repeat the above steps until all columns have been filled in with value E.
I know it is all very confusing.
I wish I could upload the layout of the table, that would clear things up, but I’m at work and cannot.
The table is several tables in one.
Think of it like a plus sign, the bottom left will tell you what row will have your answer. The top left will refine that row down even more (for every four in the bottom left, the top left has one.) the top right gives you the column you need to be in for your answer. The answer block is the bottom right.
If your totally confused, then your in the right spot… cause that’s how it is.. (and this is why I would like to create a macro to help me find my answer, and to help me reduce mistakes. )
Here is what I have to begin with...
I would like for it to update as data changes from within the cells that fill in the fields A B C and D.. I don't know how to do that ether, so for now it will run from clicking a button.
Function TableLookup ()
On Error Resume Next
Workbooks("Test.xls").Activate
RowCount = Cells(Cells.Rows.Count, "a").End(xlUp).Row
For i = 2 To RowCount
Range("a" & i).Select
Aa = ActiveCell.Value
Bb = ActiveCell.Offset(0, 1).Value
Cc = ActiveCell.Offset(0, 2).Value
Dd = ActiveCell.Offset(0, 3).Value
Workbooks("Table0026.xls").Activate
'this is where I need help
'the value will be set to "Ee"
Workbooks("Test.xls").Activate
Range("a" & i).Select
ActiveCell.Offset(0, 4).Value = Ee
Next
End Function
Any help would be very much appreciated
Thank you all!!
Qazzart.