compare between worksheets and write into cell
Hi Everyone,
I'm confronted with writing a VBA Excel Macro and I'm on beginners level So i hope I can get some insight from you on how to do this here.
This is what i want my macro to do:
I have two worksheets in one workbook (Tabelle2 and Tabelle1).
worksheet Tabelle1 contains following structure:
|
A |
B |
1 |
Entity |
BU Name |
2 |
|
Alpha |
3 |
|
Betha |
4 |
|
Delta |
5 |
|
Gamma |
Worksheet 2 contains structured data that I have to copy from another source in Tabelle2 and this is were my macro should come into play.
Worksheet 2 looks like this:
A |
B |
C |
D |
E |
1 |
|
BU_GER |
BU_FR |
|
2 |
|
Alpha |
Gamma |
|
3 |
|
Gamma |
Delta |
|
4 |
|
Delta |
|
|
So the final outcome of my macro is that in worksheet 1 in column A is written either "BU_GER" or "BU_FR" or "BU_GER and BU_FR" depending whether the worksheet 2 contains the mentioned values in column C and D.
I know it sounds kinda simple but I somehow can't get it working.
My first try is the following:
Code:
Sub findandcopy()
This.Worksheet("Tabelle2").Activate
If Range("C2").Value = This.Worksheet("Tabelle1") Range("B2").Copy Destination:=Range("A2")
' Is this even working?
Do Until IsEmpty(ActiveCell)
Loop
End Sub
I have following problems which I dont know how to solve:
1. How do I connect the cell check with an "And" condition?
2. Do I have to check every Cell? Currently I only check cell by cell.
Thanks for all your help and regards from Europe!
Oryos