Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Help! ... need to vlookup but can't make it work!

Hi -

I've got two workbooks (ITEMMOVE.xls and my basebook). The Basebook
has a list of categories (B34:B48), I need to find these categories in
ITEMMOVE and return their values (4 columns over) back to the
Basebook. For categories that don't exist in ITEMMOVE, a zero should
be returned. Ddoes that make sense? basically, a vlookup -- seems
easy but I can't get it to work....

Can you help?
TIA,
Ray


Here's my code:
Private Sub UpdateInfo_Click()
Dim ITEMMOVE As String, Store As String, ACCT As String
Dim mybook As Workbook, basebook As Workbook
Dim myR As Range, x as String

If IsError(ThisWorkbook.Sheets("Date").Range("D1").Va lue) Then
MsgBox ("You must select a store ....")
Exit Sub
Else
End If

Store = Format(ThisWorkbook.Sheets("Date").Range("D1").Val ue,
"000")

ITEMMOVE = "\\blah\blahblah\blahblahblah\ITEMMOVE.xls"


Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Set basebook = ThisWorkbook

Set mybook = Workbooks.Open(ITEMMOVE)

' Update ITEMMove info from CashRecs

basebook.Sheets("Tax Exempt").Activate
For Each cell In Range("C35:C48")
Art = cell.Offset(0, -1).Value
On Error Resume Next
x = Application.WorksheetFunction.VLookup(Art,
mybook.Sheets("Item Movement").Range("D3:D100"), 4, False)
cell.Value = x
On Error GoTo 0

Next cell
mybook.Close savechanges:=False

Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.StatusBar = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help! ... need to vlookup but can't make it work!

You can use the find method

with mybook.Sheets("Item Movement")
set c = .Range("D3:D100").find(what:=art,lookin:=xlvalues)
if not c is nothing
x = c.offset(0,3).value
end if
end with



"Ray" wrote:

Hi -

I've got two workbooks (ITEMMOVE.xls and my basebook). The Basebook
has a list of categories (B34:B48), I need to find these categories in
ITEMMOVE and return their values (4 columns over) back to the
Basebook. For categories that don't exist in ITEMMOVE, a zero should
be returned. Ddoes that make sense? basically, a vlookup -- seems
easy but I can't get it to work....

Can you help?
TIA,
Ray


Here's my code:
Private Sub UpdateInfo_Click()
Dim ITEMMOVE As String, Store As String, ACCT As String
Dim mybook As Workbook, basebook As Workbook
Dim myR As Range, x as String

If IsError(ThisWorkbook.Sheets("Date").Range("D1").Va lue) Then
MsgBox ("You must select a store ....")
Exit Sub
Else
End If

Store = Format(ThisWorkbook.Sheets("Date").Range("D1").Val ue,
"000")

ITEMMOVE = "\\blah\blahblah\blahblahblah\ITEMMOVE.xls"


Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Set basebook = ThisWorkbook

Set mybook = Workbooks.Open(ITEMMOVE)

' Update ITEMMove info from CashRecs

basebook.Sheets("Tax Exempt").Activate
For Each cell In Range("C35:C48")
Art = cell.Offset(0, -1).Value
On Error Resume Next
x = Application.WorksheetFunction.VLookup(Art,
mybook.Sheets("Item Movement").Range("D3:D100"), 4, False)
cell.Value = x
On Error GoTo 0

Next cell
mybook.Close savechanges:=False

Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.StatusBar = True

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help! ... need to vlookup but can't make it work!

x
x = Application.WorksheetFunction.VLookup(Art,
mybook.Sheets("Item Movement").Range("D3:G100"), 4, False)

the lookup range must be at least 4 columns wide


As adjusted above it looks for the categories in column D and returns vaues
from F. Make adjustments as appropriate.
--
Regards,
Tom Ogilvy



"Ray" wrote:

Hi -

I've got two workbooks (ITEMMOVE.xls and my basebook). The Basebook
has a list of categories (B34:B48), I need to find these categories in
ITEMMOVE and return their values (4 columns over) back to the
Basebook. For categories that don't exist in ITEMMOVE, a zero should
be returned. Ddoes that make sense? basically, a vlookup -- seems
easy but I can't get it to work....

Can you help?
TIA,
Ray


Here's my code:
Private Sub UpdateInfo_Click()
Dim ITEMMOVE As String, Store As String, ACCT As String
Dim mybook As Workbook, basebook As Workbook
Dim myR As Range, x as String

If IsError(ThisWorkbook.Sheets("Date").Range("D1").Va lue) Then
MsgBox ("You must select a store ....")
Exit Sub
Else
End If

Store = Format(ThisWorkbook.Sheets("Date").Range("D1").Val ue,
"000")

ITEMMOVE = "\\blah\blahblah\blahblahblah\ITEMMOVE.xls"


Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Set basebook = ThisWorkbook

Set mybook = Workbooks.Open(ITEMMOVE)

' Update ITEMMove info from CashRecs

basebook.Sheets("Tax Exempt").Activate
For Each cell In Range("C35:C48")
Art = cell.Offset(0, -1).Value
On Error Resume Next
x = Application.WorksheetFunction.VLookup(Art,
mybook.Sheets("Item Movement").Range("D3:D100"), 4, False)
cell.Value = x
On Error GoTo 0

Next cell
mybook.Close savechanges:=False

Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.StatusBar = True

End Sub


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
Looking for a way to make this work. Darryl_Neeley Excel Worksheet Functions 8 September 27th 07 05:06 PM
Make table query will work in datasheet view but will not make tab WildlyHarry Excel Discussion (Misc queries) 0 August 28th 07 03:06 PM
Cant make it work Bama_Buc New Users to Excel 2 August 14th 06 08:43 PM
can't make it work, I need help kynhart Excel Worksheet Functions 2 October 19th 05 05:58 AM
Spin button in a work sheet - how do I make it work? [email protected] Excel Worksheet Functions 1 April 7th 05 08:43 PM


All times are GMT +1. The time now is 09:06 AM.

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"