#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Lookup

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Lookup

Just some more information.

In last weeks worksheet, I have two columns (among others) that contain a
workorder and a date.

Trav BP Week
H623601 11/7/05
H623619 11/7/05
H815003 11/7/05
H815011 11/7/05

This week, I have just the workorder and would like to add the dates through
VBA

Trav BP Week
H815003
H815011
J456809
J456787

Suggestions would be appreciated.




"Byron" wrote:

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA Lookup

I would think that the easiest thing to do would be to just use =vlookup().

With both worksheets in the same workbook...

Option Explicit
Sub testme01()

Dim LastWks As Worksheet
Dim ThisWks As Worksheet
Dim DateRng As Range

Set LastWks = Worksheets("lastweek")
Set ThisWks = Worksheets("ThisWeek")

With ThisWks
Set DateRng = .Range("b2:b" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With DateRng
.FormulaR1C1 = "=vlookup(rc[-1]," _
& LastWks.Range("a:b") _
.Address(ReferenceStyle:=xlR1C1, external:=True) _
& ",2,false)"
.Value = .Value
.Replace what:="#n/a", replacement:="", _
lookat:=xlWhole, MatchCase:=False
End With

End Sub

Byron wrote:

Just some more information.

In last weeks worksheet, I have two columns (among others) that contain a
workorder and a date.

Trav BP Week
H623601 11/7/05
H623619 11/7/05
H815003 11/7/05
H815011 11/7/05

This week, I have just the workorder and would like to add the dates through
VBA

Trav BP Week
H815003
H815011
J456809
J456787

Suggestions would be appreciated.



"Byron" wrote:

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Lookup

Thanks for the solution. It works great, but I have these two worksheets in
seperate workbooks with multiple other worksheets. Is there a way to make
this suggestion work arcross two workbooks. Thanks

"Dave Peterson" wrote:

I would think that the easiest thing to do would be to just use =vlookup().

With both worksheets in the same workbook...

Option Explicit
Sub testme01()

Dim LastWks As Worksheet
Dim ThisWks As Worksheet
Dim DateRng As Range

Set LastWks = Worksheets("lastweek")
Set ThisWks = Worksheets("ThisWeek")

With ThisWks
Set DateRng = .Range("b2:b" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With DateRng
.FormulaR1C1 = "=vlookup(rc[-1]," _
& LastWks.Range("a:b") _
.Address(ReferenceStyle:=xlR1C1, external:=True) _
& ",2,false)"
.Value = .Value
.Replace what:="#n/a", replacement:="", _
lookat:=xlWhole, MatchCase:=False
End With

End Sub

Byron wrote:

Just some more information.

In last weeks worksheet, I have two columns (among others) that contain a
workorder and a date.

Trav BP Week
H623601 11/7/05
H623619 11/7/05
H815003 11/7/05
H815011 11/7/05

This week, I have just the workorder and would like to add the dates through
VBA

Trav BP Week
H815003
H815011
J456809
J456787

Suggestions would be appreciated.



"Byron" wrote:

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA Lookup

Both workbooks need to be open.

Set LastWks = workbooks("Firstworkbookname.xls").Worksheets("las tweek")
Set ThisWks = workbooks("Secondworkbookname.xls").Worksheets("Th isWeek")



Byron wrote:

Thanks for the solution. It works great, but I have these two worksheets in
seperate workbooks with multiple other worksheets. Is there a way to make
this suggestion work arcross two workbooks. Thanks

"Dave Peterson" wrote:

I would think that the easiest thing to do would be to just use =vlookup().

With both worksheets in the same workbook...

Option Explicit
Sub testme01()

Dim LastWks As Worksheet
Dim ThisWks As Worksheet
Dim DateRng As Range

Set LastWks = Worksheets("lastweek")
Set ThisWks = Worksheets("ThisWeek")

With ThisWks
Set DateRng = .Range("b2:b" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With DateRng
.FormulaR1C1 = "=vlookup(rc[-1]," _
& LastWks.Range("a:b") _
.Address(ReferenceStyle:=xlR1C1, external:=True) _
& ",2,false)"
.Value = .Value
.Replace what:="#n/a", replacement:="", _
lookat:=xlWhole, MatchCase:=False
End With

End Sub

Byron wrote:

Just some more information.

In last weeks worksheet, I have two columns (among others) that contain a
workorder and a date.

Trav BP Week
H623601 11/7/05
H623619 11/7/05
H815003 11/7/05
H815011 11/7/05

This week, I have just the workorder and would like to add the dates through
VBA

Trav BP Week
H815003
H815011
J456809
J456787

Suggestions would be appreciated.



"Byron" wrote:

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VBA Lookup

Works great. Thank you for your patience.

Byron

"Dave Peterson" wrote:

Both workbooks need to be open.

Set LastWks = workbooks("Firstworkbookname.xls").Worksheets("las tweek")
Set ThisWks = workbooks("Secondworkbookname.xls").Worksheets("Th isWeek")



Byron wrote:

Thanks for the solution. It works great, but I have these two worksheets in
seperate workbooks with multiple other worksheets. Is there a way to make
this suggestion work arcross two workbooks. Thanks

"Dave Peterson" wrote:

I would think that the easiest thing to do would be to just use =vlookup().

With both worksheets in the same workbook...

Option Explicit
Sub testme01()

Dim LastWks As Worksheet
Dim ThisWks As Worksheet
Dim DateRng As Range

Set LastWks = Worksheets("lastweek")
Set ThisWks = Worksheets("ThisWeek")

With ThisWks
Set DateRng = .Range("b2:b" & .Cells(.Rows.Count, "A").End(xlUp).Row)
End With

With DateRng
.FormulaR1C1 = "=vlookup(rc[-1]," _
& LastWks.Range("a:b") _
.Address(ReferenceStyle:=xlR1C1, external:=True) _
& ",2,false)"
.Value = .Value
.Replace what:="#n/a", replacement:="", _
lookat:=xlWhole, MatchCase:=False
End With

End Sub

Byron wrote:

Just some more information.

In last weeks worksheet, I have two columns (among others) that contain a
workorder and a date.

Trav BP Week
H623601 11/7/05
H623619 11/7/05
H815003 11/7/05
H815011 11/7/05

This week, I have just the workorder and would like to add the dates through
VBA

Trav BP Week
H815003
H815011
J456809
J456787

Suggestions would be appreciated.



"Byron" wrote:

I have a worksheet that has work orders and build dates from last week
(occurs weekly by hand presently). I would like to transfer the dates to the
new worksheet in a new workbook for those work orders that are still present.
I have been using a VLOOKUP, is there a way to do this, line by line in VBA?

Thanks.

--

Dave Peterson


--

Dave Peterson

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
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
Matrix lookup/mulitple criteria lookup MarkFranklin Excel Discussion (Misc queries) 3 March 31st 08 10:15 AM
Get Cell Address From Lookup (Alternative to Lookup) ryguy7272 Excel Worksheet Functions 12 September 28th 07 10:36 PM
Join 2 Lists - Lookup value in 1 list & use result in 2nd lookup JBush Excel Worksheet Functions 3 January 3rd 07 11:14 PM


All times are GMT +1. The time now is 04:08 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"