JazzBeatles
Technical User
Hey all--I've recently taken up learning VBA in an attempt to automate several of my company's datasheets and thus shave off countless hours of sorting through the jumbled mess.
As a C++ programmer, I know that VBA is more like a first language for some people. It's more like my 23rd language. That being said, I would like a little help on some code attemping to accomplish this task:
Search Sheet One for a match in Sheet Two; then copy a block of data in Sheet One(ie. 2 rows and 20 collumns) one collumn to the right of the matched data to Sheet Two.
Sample would be:
SHEET ONE SHEET TWO
Emp 2 2 22 222 Emp 1
B BB BBB
Emp 1 1 11 111 Emp 2
A AA AAA
Emp 3 3 33 333 Emp 3
C CC CCC
After the code runs, the outcome should be:
SHEET ONE SHEET TWO
Emp 2 2 22 222 Emp 1 1 11 111
B BB BBB A AA AAA
Emp 1 1 11 111 Emp 2 2 22 111
A AA AAA B BB BBB
Emp 3 3 33 333 Emp 3 3 33 333
C CC CCC C CC CCC
The code should sift through the information and return the matches with the data in blocks to the right of it. I've tried an Excel vlookup solution, but too many imbedded functions like offset prevented it from working properly. I'm currently trying to get the VBA Find function to accomplish this, but I just need a little push in the right direction if I'm even going about this the right way. Recording macros doesn't help since both sheets, the source and the output will be dynamic in their criteria. I've tried vlookup, match, offset etc. in Excel to no avail. I'm sure this has to be fairly simple code in VB, as at its essence I just need it to find a match then return a range of data to the right of the match.
Thank you all in advance for any help rendered. I surely appreciate it.
As a C++ programmer, I know that VBA is more like a first language for some people. It's more like my 23rd language. That being said, I would like a little help on some code attemping to accomplish this task:
Search Sheet One for a match in Sheet Two; then copy a block of data in Sheet One(ie. 2 rows and 20 collumns) one collumn to the right of the matched data to Sheet Two.
Sample would be:
SHEET ONE SHEET TWO
Emp 2 2 22 222 Emp 1
B BB BBB
Emp 1 1 11 111 Emp 2
A AA AAA
Emp 3 3 33 333 Emp 3
C CC CCC
After the code runs, the outcome should be:
SHEET ONE SHEET TWO
Emp 2 2 22 222 Emp 1 1 11 111
B BB BBB A AA AAA
Emp 1 1 11 111 Emp 2 2 22 111
A AA AAA B BB BBB
Emp 3 3 33 333 Emp 3 3 33 333
C CC CCC C CC CCC
The code should sift through the information and return the matches with the data in blocks to the right of it. I've tried an Excel vlookup solution, but too many imbedded functions like offset prevented it from working properly. I'm currently trying to get the VBA Find function to accomplish this, but I just need a little push in the right direction if I'm even going about this the right way. Recording macros doesn't help since both sheets, the source and the output will be dynamic in their criteria. I've tried vlookup, match, offset etc. in Excel to no avail. I'm sure this has to be fairly simple code in VB, as at its essence I just need it to find a match then return a range of data to the right of the match.
Thank you all in advance for any help rendered. I surely appreciate it.