Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default look to do an Offset of something like a offset

I am look to do an Offset of something like a offset. I level data in
column "A" and Part Number in Column "B". What I need to do is look
at the level data for "1, 2, 3, 4, ets." Then lookup the table for the
first value that is equal to data -1 and report out the Part Number
from its column "B".

Data
A B
1 P1
2 P2
3 P3
3 P4
4 P5

Results
A B C
0 P
1 P1 P
2 P2 P1
3 P3 P2
3 P4 P2
4 P5 P4
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default look to do an Offset of something like a offset

I am assuming you have one worksheet with the data which I have named "Data"
and another worksheet with results which I have named "Results". This sub
will look in the "Data" sheet for each level from "Results" and place the
part number in Col.B in the "Results" sheet. You can change the names to fit
your application.

Option Explicit

Sub LookUpParts()

Dim lngLastRow As Long
Dim rngResults As Range
Dim cell As Range

lngLastRow = Sheets("Results").Cells(Rows.Count, "A").End(xlUp).Row
Set rngResults = Sheets("Results").Range("A1:A" & lngLastRow)

For Each cell In rngResults
On Error Resume Next
cell.Offset(0, 1) = WorksheetFunction.VLookup(cell.Value,
Sheets("Data").Range("A:B"), 2, False)
On Error GoTo 0
Next cell

End Sub

Hope this helps! If so, please click "YES" below.
--
Cheers,
Ryan


"B~O~B" wrote:

I am look to do an Offset of something like a offset. I level data in
column "A" and Part Number in Column "B". What I need to do is look
at the level data for "1, 2, 3, 4, ets." Then lookup the table for the
first value that is equal to data -1 and report out the Part Number
from its column "B".

Data
A B
1 P1
2 P2
3 P3
3 P4
4 P5

Results
A B C
0 P
1 P1 P
2 P2 P1
3 P3 P2
3 P4 P2
4 P5 P4

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default look to do an Offset of something like a offset

On Nov 10, 11:01*pm, RyanH wrote:
I am assuming you have one worksheet with the data which I have named "Data"
and another worksheet with results which I have named "Results". *This sub
will look in the "Data" sheet for each level from "Results" and place the
part number in Col.B in the "Results" sheet. *You can change the names to fit
your application.

Option Explicit

Sub LookUpParts()

Dim lngLastRow As Long
Dim rngResults As Range
Dim cell As Range

* * lngLastRow = Sheets("Results").Cells(Rows.Count, "A").End(xlUp)..Row
* * Set rngResults = Sheets("Results").Range("A1:A" & lngLastRow)

* * For Each cell In rngResults
* * * * On Error Resume Next
* * * * cell.Offset(0, 1) = WorksheetFunction.VLookup(cell.Value,
Sheets("Data").Range("A:B"), 2, False)
* * * * On Error GoTo 0
* * Next cell

End Sub

Hope this helps! *If so, please click "YES" below.
--
Cheers,
Ryan



"B~O~B" wrote:
I am look to do an Offset of something like a offset. *I level data in
column "A" and Part Number in Column "B". *What I need to do is look
at the level data for "1, 2, 3, 4, ets." Then lookup the table for the
first value that is equal to data -1 and report out the Part Number
from its column "B".


Data
A * * * *B
1 * * * * P1
2 * * * * P2
3 * * * * P3
3 * * * * P4
4 * * * * P5


Results
A * * * *B * * *C
0 * * * * P
1 * * * * P1 * *P
2 * * * * P2 * *P1
3 * * * * P3 * *P2
3 * * * * P4 * *P2
4 * * * * P5 * *P4- Hide quoted text -


- Show quoted text -


Ryan,

Thanks for the help, but, I was not able to get it working. I
generated the two sheet and added the data i ran it... It did
nothing...
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
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Programming 4 September 28th 07 09:59 PM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny[_3_] Excel Programming 10 December 7th 06 11:46 PM
select offset (variable ,1) to offset(variable ,variable) Buffyslay Excel Programming 1 November 15th 06 11:45 AM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM


All times are GMT +1. The time now is 03:09 PM.

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

About Us

"It's about Microsoft Excel"