#1   Report Post  
Kerry
 
Posts: n/a
Default lookup and if?

I have 2 sheets ... I need to do a query that says IF a number is
input into a cell (in a large array ie c1:z26) in sheet two , THEN the name
that
corresponds in that row(a1:a26) will be input into a certain cell in sheet
one (aa1:zz52).
The columns dont match up..

ARGH PLEASE HELP!!!
Thanks,
KAM

  #2   Report Post  
Webtest
 
Posts: n/a
Default lookup and if?

First of all, "zz52" is not a valid cell reference in Excel. "IV" is column
256, which is the maximum available column. For the first part of your
question, here is code to iterate through the input range and find the
correct text from column A:
Code:
Option Explicit
Sub Macro1()
Dim iRange As Range
Dim iSheet As Worksheet  'Input Sheet Handle
Dim oSheet As Worksheet  'Output Sheet Handle
Dim aCell As Range
Dim tStr As String
Dim aRow As Long
Dim aCol As Long

'Set the handle and range on the Input Sheet
Set iSheet = ActiveWorkbook.Sheets("Sheet2")
Set iRange = iSheet.Range("C1:Z26")
'Set the handle to the Output Sheet
Set oSheet = ActiveWorkbook.Sheets("Sheet1")

'Iterate through the Input Range
For Each aCell In iRange
'If the cell contains a number in the range of 1 to 26
If aCell.Value  0 And aCell.Value <= 26 Then
'These are the references for the source cell:
aRow = aCell.Row
aCol = aCell.Column
'Pull the text from Column A from the row enumerated in the
current cell
tStr = iSheet.Cells(aCell.Value, "A").Text
'TEST TEST TEST TEST
'MsgBox tStr
'END TEST
'Here is where you load Sheet 1, but you don't say where to put
the data ???
'This will load your lookup text into the same relative cell
reference on Sheet 1
'You need to figure out exactly what you want to do here ...
oSheet.Cells(aRow, aCol).Value = tStr

Else
tStr = ""
End If
Next

End Sub

"Kerry" wrote:

I have 2 sheets ... I need to do a query that says IF a number is
input into a cell (in a large array ie c1:z26) in sheet two , THEN the name
that
corresponds in that row(a1:a26) will be input into a certain cell in sheet
one (aa1:zz52).
The columns dont match up..

ARGH PLEASE HELP!!!
Thanks,
KAM

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another way to lookup data David Vollmer Excel Worksheet Functions 1 September 23rd 05 05:16 AM
lookup more than one cell andrewm Excel Worksheet Functions 20 June 14th 05 05:33 AM
Lookup Vector > Lookup Value Alec Kolundzic Excel Worksheet Functions 6 June 10th 05 02:14 PM
Lookup function w/Text and Year Josh O. Excel Worksheet Functions 1 February 12th 05 11:27 PM
double lookup, nest, or macro? Josef.angel Excel Worksheet Functions 1 October 29th 04 09:50 AM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"