Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jeff
 
Posts: n/a
Default VLookup and IF with VBA

I need to design a VBA formula for the following:

In worksheet Billable Jobs, I want to do Vlookup of the value of row E3
in table_Array = worksheet VBPA in Col_index_num Column D if and only if
in the column C there the text JC



--
Regards,
Jeff

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet Billable Jobs, I want to do Vlookup of the value of row E3
in table_Array = worksheet VBPA in Col_index_num Column D if and only if
in the column C there the text JC

--
Regards,
Jeff


--

Dave Peterson
  #3   Report Post  
Jeff
 
Posts: n/a
Default

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff



"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet âœBillable Jobsâ, I want to do Vlookup of the value of row âœE3â
in table_Array = worksheet âœVBPA❠in Col_index_num Column âœD❠if and only if
in the column âœC❠there the text âœJCâ

--
Regards,
Jeff


--

Dave Peterson

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet âœBillable Jobsâ, I want to do Vlookup of the value of row âœE3â
in table_Array = worksheet âœVBPA❠in Col_index_num Column âœD❠if and only if
in the column âœC❠there the text âœJCâ

--
Regards,
Jeff


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Jeff
 
Posts: n/a
Default

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet ââ¬ÅBillable Jobsââ¬Â, I want to do Vlookup of the value of row ââ¬ÅE3ââ¬Â
in table_Array = worksheet ââ¬ÅVBPAââ¬Â in Col_index_num Column ââ¬ÅDââ¬Â if and only if
in the column ââ¬ÅCââ¬Â there the text ââ¬ÅJCââ¬Â

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

Then use the first.

Jeff wrote:

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet ââ¬ÅBillable Jobsââ¬Â, I want to do Vlookup of the value of row ââ¬ÅE3ââ¬Â
in table_Array = worksheet ââ¬ÅVBPAââ¬Â in Col_index_num Column ââ¬ÅDââ¬Â if and only if
in the column ââ¬ÅCââ¬Â there the text ââ¬ÅJCââ¬Â

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Jeff
 
Posts: n/a
Default

Thank you.

Would you know if there's way to make it more dynamic. If I wanted to
evaluate the column E in Billable Job. to column C in VBPA?
--
Regards,
Jeff



"Dave Peterson" wrote:

Then use the first.

Jeff wrote:

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet âââšÂ¬ÃâœBillable JobsâââšÂ¬Ã, I want to do Vlookup of the value of row âââšÂ¬ÃâœE3â⠚¬Ý
in table_Array = worksheet âââšÂ¬ÃâœVBPAâà âšÂ¬Ã in Col_index_num Column âââšÂ¬ÃâœDââ⠚¬Ã if and only if
in the column âââšÂ¬ÃâœCââ⠚¬Ã there the text âââšÂ¬ÃâœJCâ⠚¬Ý

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #8   Report Post  
Dave Peterson
 
Posts: n/a
Default

I'm not sure how the dynamic portion comes in, but if you qualify the ranges,
you'll be ok.

But if you have rules, you could use something like:

Dim CellToCheckForJC as range
dim CellWithValueToMatch as range

if something = true then
set celltocheckforjc = worksheets("sheet99").range("d43")
else
set celltocheckforjc = worksheets("sheet001").range("F99")
end if

if somethingelse = true then
set CellWithValueToMatch = worksheets("sheet108").range("a1")
else
set CellWithValueToMatch = worksheets("sheet2").range("b99")
end if

'then just use those ranges:

if ucase(celltocheckforjc.value) = "JC" then
res = application.vlookup(cellwithvaluetomatch.value, _
lookuprng,col_index_num,0)
''''and so on...


Jeff wrote:

Thank you.

Would you know if there's way to make it more dynamic. If I wanted to
evaluate the column E in Billable Job. to column C in VBPA?
--
Regards,
Jeff

"Dave Peterson" wrote:

Then use the first.

Jeff wrote:

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet âââšÂ¬ÃâœBillable JobsâââšÂ¬Ã, I want to do Vlookup of the value of row âââšÂ¬ÃâœE3â⠚¬Ý
in table_Array = worksheet âââšÂ¬ÃâœVBPAâà âšÂ¬Ã in Col_index_num Column âââšÂ¬ÃâœDââ⠚¬Ã if and only if
in the column âââšÂ¬ÃâœCââ⠚¬Ã there the text âââšÂ¬ÃâœJCâ⠚¬Ý

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Jeff
 
Posts: n/a
Default

Thank you it worked
how can I put the value of "res" in row F3?

--
Regards,
Jeff



"Dave Peterson" wrote:

I'm not sure how the dynamic portion comes in, but if you qualify the ranges,
you'll be ok.

But if you have rules, you could use something like:

Dim CellToCheckForJC as range
dim CellWithValueToMatch as range

if something = true then
set celltocheckforjc = worksheets("sheet99").range("d43")
else
set celltocheckforjc = worksheets("sheet001").range("F99")
end if

if somethingelse = true then
set CellWithValueToMatch = worksheets("sheet108").range("a1")
else
set CellWithValueToMatch = worksheets("sheet2").range("b99")
end if

'then just use those ranges:

if ucase(celltocheckforjc.value) = "JC" then
res = application.vlookup(cellwithvaluetomatch.value, _
lookuprng,col_index_num,0)
''''and so on...


Jeff wrote:

Thank you.

Would you know if there's way to make it more dynamic. If I wanted to
evaluate the column E in Billable Job. to column C in VBPA?
--
Regards,
Jeff

"Dave Peterson" wrote:

Then use the first.

Jeff wrote:

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅBillable Jobs̢̢̮ââ¬Å¡Ã ¬ÃâšÃ, I want to do Vlookup of the value of row ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅE3ÃÆÃ¢à ¢ââ¬Å¡Ã¬ÃâšÃ
in table_Array = worksheet ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅVBPA̢̮ ƒÂ¢Ã¢â¬Å¡Ã¬ÃâšÃ in Col_index_num Column ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅDÃÆÃ¢Ã ¢ââ¬Å¡Ã¬ÃâšÃ if and only if
in the column ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅCÃÆÃ¢Ã ¢ââ¬Å¡Ã¬ÃâšÃ there the text ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅJCÃÆÃ¢à ¢ââ¬Å¡Ã¬ÃâšÃ

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #10   Report Post  
Dave Peterson
 
Posts: n/a
Default

if iserror(res) then
res = "Missing in table" 'or whatever you want to see
end if
worksheets("YouDidn'tSayWhatOne").range("F3").valu e = res



Jeff wrote:

Thank you it worked
how can I put the value of "res" in row F3?

--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure how the dynamic portion comes in, but if you qualify the ranges,
you'll be ok.

But if you have rules, you could use something like:

Dim CellToCheckForJC as range
dim CellWithValueToMatch as range

if something = true then
set celltocheckforjc = worksheets("sheet99").range("d43")
else
set celltocheckforjc = worksheets("sheet001").range("F99")
end if

if somethingelse = true then
set CellWithValueToMatch = worksheets("sheet108").range("a1")
else
set CellWithValueToMatch = worksheets("sheet2").range("b99")
end if

'then just use those ranges:

if ucase(celltocheckforjc.value) = "JC" then
res = application.vlookup(cellwithvaluetomatch.value, _
lookuprng,col_index_num,0)
''''and so on...


Jeff wrote:

Thank you.

Would you know if there's way to make it more dynamic. If I wanted to
evaluate the column E in Billable Job. to column C in VBPA?
--
Regards,
Jeff

"Dave Peterson" wrote:

Then use the first.

Jeff wrote:

Hi,
(which sheet owns E3) billable jobs
E3 is in billable jobs
--
Regards,
Jeff

"Dave Peterson" wrote:

I'm not sure what should be looked up (which sheet owns E3)??


maybe...

with worksheets("billable jobs")
if ucase(worksheets("vbpa").range("C3").value) = "JC" then

Or maybe...

with worksheets("VBPA")
if ucase(.range("C3").value) = "JC" then



Jeff wrote:

Thank you.
The only thingis that "JC" is in the VBPA worksheet.

--
Regards,
Jeff

"Dave Peterson" wrote:

Maybe...

Option explicit
sub testme()
dim lookupRng as range
dim res as variant
dim col_index_num as long

'include more columns if necessary
set lookuprng = worksheets("VBPA").range("a:Z")

col_index_num = 13 'what should it be?

with worksheets("billable jobs")
if ucase(.range("C3").value) = "JC" then
res = application.vlookup(.range("E3").value, lookuprng,col_index_num,0)
if iserror(res) then
'there was no match
else
msgbox "returned: " & res
end if
end if
end with
end sub

(If I understood your references correctly.)



Jeff wrote:

I need to design a VBA formula for the following:

In worksheet ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅBillable Jobs̢̢̮ââ¬Å¡Ã ¬ÃâšÃ, I want to do Vlookup of the value of row ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅE3ÃÆÃ¢à ¢ââ¬Å¡Ã¬ÃâšÃ
in table_Array = worksheet ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅVBPA̢̮ ƒÂ¢Ã¢â¬Å¡Ã¬ÃâšÃ in Col_index_num Column ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅDÃÆÃ¢Ã ¢ââ¬Å¡Ã¬ÃâšÃ if and only if
in the column ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅCÃÆÃ¢Ã ¢ââ¬Å¡Ã¬ÃâšÃ there the text ̢̢̮ââ¬Å¡Ã¬ Ãâ¦Ã¢â¬ÅJCÃÆÃ¢à ¢ââ¬Å¡Ã¬ÃâšÃ

--
Regards,
Jeff

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

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
VLOOKUP Limitations chris_manning Excel Worksheet Functions 2 August 9th 05 06:23 PM
VLOOKUP Question. StephenAccountant Excel Discussion (Misc queries) 3 July 6th 05 10:28 PM
Have Vlookup return a Value of 0 instead of #N/A Mr Mike Excel Worksheet Functions 4 May 25th 05 04:51 PM
vlookup data hidden within worksheet Excel Worksheet Functions 0 January 26th 05 12:09 PM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


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

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"