View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Know Enough to be Dangerous Know Enough to be Dangerous is offline
external usenet poster
 
Posts: 4
Default VBA for Lookup to other Columns

Hello-

I am hoping someone can help me. I'm having a hard time coming up
with the proper code to solve the following problem.

I need to populate column H (starting with cell H8) with an amount
that can be in 1 of 12 different columns to the right. Which column
of data to pull back is dependent on the number in column F. Here's
an example:

If cell F8 contains the number 1, the amount in cell H8 needs to come
from column Y and same row number (e.g., Y8). If cell F8 contains the
number 2, the amount in cell H8 needs to come from column Z and the
same row number (e.g., Z8). As you'd guess a 3 in F results in
returning the number from AA and so on. Column F will only contain
the number range of 1 - 12.

Below is chart outling the number in column F and the associated
column to pull from to populate H:
1=Y
2=Z
3=AA
4=AB
5=AC
6=AD
7=AE
8=AF
9=AG
10=AH
11=AI
12=AJ

The code would need to loop for every non-blank cell in column F
starting with cell F8. The range this would be applied to is
variable, so it would have to loop until it finds a blank in column F.

Thank you very much in advance.