Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Vlookup errors


hi, im using the vlookup function


Code:
--------------------

=VLOOKUP("d",Hidden!$A$2:$K$134,1,FALSE)

--------------------


where this code says that it will look up d in the tab sheet hidden, in
the range A2 to K134, where 1 is the column value to return and false
makes sure it finds d.

Thats all well and gravy, but, i would like to write some code more
like this:


Code:
--------------------

Sub Macro_ChangeData()

Dim Stringd As String
Stringd = InputBox("Please enter an Employee's first initial followed by second name, e.g. 'A McMorland'")
Range("C9").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,1,FALSE )"
Range("C11").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,2,FALSE )"
Range("C13").Formula = "=VLOOKUP("Stringd ",Hidden!$A$2:$K$134,3,FALSE)"
Range("C15").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,4,FALSE )"
Range("C17").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,5,FALSE )"
Range("C19").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,6,FALSE )"
Range("C21").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,7,FALSE )"
Range("C23").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,8,FALSE )"
Range("C25").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,9,FALSE )"
Range("C27").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,10,FALS E)"
Range("C29").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,11,FALS E)"
End If

End Sub

--------------------


The only thing wrong with this code is that the second set of quotation
marks, around "Stringd" returns the error: Unexpected End of Statement

What i want it to do is when the user puts a name into a text box that
stringd becomes that name and then when that happens all the formulas
to the cells i have put above to be equal to the text that follows
them.

Can anyone see any errors as to why this doesn't work?
Also can anyone provide the correct code?

Thanks


--
alymcmorland
------------------------------------------------------------------------
alymcmorland's Profile: http://www.excelforum.com/member.php...o&userid=27652
View this thread: http://www.excelforum.com/showthread...hreadid=484790

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Vlookup errors

For quotes within quotes, use two quotes

--
Kind regards,

Niek Otten

"alymcmorland"
wrote in message
news:alymcmorland.1yhfbm_1131963902.2506@excelforu m-nospam.com...

hi, im using the vlookup function


Code:
--------------------

=VLOOKUP("d",Hidden!$A$2:$K$134,1,FALSE)

--------------------


where this code says that it will look up d in the tab sheet hidden, in
the range A2 to K134, where 1 is the column value to return and false
makes sure it finds d.

Thats all well and gravy, but, i would like to write some code more
like this:


Code:
--------------------

Sub Macro_ChangeData()

Dim Stringd As String
Stringd = InputBox("Please enter an Employee's first initial followed by
second name, e.g. 'A McMorland'")
Range("C9").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,1,FALSE )"
Range("C11").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,2,FALSE )"
Range("C13").Formula = "=VLOOKUP("Stringd ",Hidden!$A$2:$K$134,3,FALSE)"
Range("C15").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,4,FALSE )"
Range("C17").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,5,FALSE )"
Range("C19").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,6,FALSE )"
Range("C21").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,7,FALSE )"
Range("C23").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,8,FALSE )"
Range("C25").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,9,FALSE )"
Range("C27").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,10,FALS E)"
Range("C29").Formula = "=VLOOKUP("Stringd",Hidden!$A$2:$K$134,11,FALS E)"
End If

End Sub

--------------------


The only thing wrong with this code is that the second set of quotation
marks, around "Stringd" returns the error: Unexpected End of Statement

What i want it to do is when the user puts a name into a text box that
stringd becomes that name and then when that happens all the formulas
to the cells i have put above to be equal to the text that follows
them.

Can anyone see any errors as to why this doesn't work?
Also can anyone provide the correct code?

Thanks


--
alymcmorland
------------------------------------------------------------------------
alymcmorland's Profile:
http://www.excelforum.com/member.php...o&userid=27652
View this thread: http://www.excelforum.com/showthread...hreadid=484790



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Vlookup errors


Ok i changed all the quotes within quotes to double quotes, so now th
code seems fine but, when i try put a name in all the cells just retur
the value "#N/A" and the error says value not available.

Does anyone have any idea as to why this might be happening

--
alymcmorlan
-----------------------------------------------------------------------
alymcmorland's Profile: http://www.excelforum.com/member.php...fo&userid=2765
View this thread: http://www.excelforum.com/showthread.php?threadid=48479

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Vlookup errors

Range("C9").Formula = "=VLOOKUP(""" & Stringd &
""",Hidden!$A$2:$K$134,1,FALSE)"

--
Kind regards,

Niek Otten

"alymcmorland"
wrote in message
news:alymcmorland.1yhg8z_1131965103.3351@excelforu m-nospam.com...

Ok i changed all the quotes within quotes to double quotes, so now the
code seems fine but, when i try put a name in all the cells just return
the value "#N/A" and the error says value not available.

Does anyone have any idea as to why this might be happening?


--
alymcmorland
------------------------------------------------------------------------
alymcmorland's Profile:
http://www.excelforum.com/member.php...o&userid=27652
View this thread: http://www.excelforum.com/showthread...hreadid=484790



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Vlookup errors


thank you very much, that works perfectly, so what does the & and
quotation marks declare to excel?


--
alymcmorland
------------------------------------------------------------------------
alymcmorland's Profile: http://www.excelforum.com/member.php...o&userid=27652
View this thread: http://www.excelforum.com/showthread...hreadid=484790



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Vlookup errors

The & concatenate three parts of the formula to one string.
First part: Range("C9").Formula = "=VLOOKUP("
Second part: Stringd
Third part: ",Hidden!$A$2:$K$134,1,FALSE)"

--
Kind regards,

Niek Otten


"alymcmorland"
wrote in message
news:alymcmorland.1yhhva_1131967202.8109@excelforu m-nospam.com...

thank you very much, that works perfectly, so what does the & and
quotation marks declare to excel?


--
alymcmorland
------------------------------------------------------------------------
alymcmorland's Profile:
http://www.excelforum.com/member.php...o&userid=27652
View this thread: http://www.excelforum.com/showthread...hreadid=484790



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 errors #n/a [email protected] Excel Worksheet Functions 10 November 9th 08 12:39 AM
VLOOKUP AND N/A ERRORS amy howell Excel Discussion (Misc queries) 6 March 31st 08 02:46 AM
VLOOKUP returning errors Dave F Excel Worksheet Functions 4 September 6th 06 06:35 PM
VLookup Errors Erika Excel Worksheet Functions 4 May 20th 05 01:25 AM
errors using Vlookup BLW Excel Worksheet Functions 1 May 19th 05 06:18 PM


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