Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
R R is offline
external usenet poster
 
Posts: 3
Default How to format a cell with VBA to return a value from a database?

I need to write a program for construction estimating for my company.
Nothing fancy, justa little something to make my life easier. Since I
never know how many items I will need to lookup, I want to have the
userform update the excel cells as needed.
Here is the code I am trying to get to work. It looks at the previous
cell in the row for a match description. If it finds one, I need it to
lookup the value in the pricing database and return the value in the
cell.

=IF($K18="","",VLOOKUP($K18,'C:\Templates\pricing. xls'!OIGDB,3,FALSE))

example
Lets say in the description cell it finds "30 year shingles"
It then goes to the pricing database and findes "square foot" for
column 3 so will show "square foot" in the cell.
I hope this makes sense.

Thank you for any help.
Rob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default How to format a cell with VBA to return a value from a database?

Rob

Do you need VB? I think you could use an advanced filter with your lookup
formula as a criterion.

Try the Help on filters and try debra dalgliesh's site for great tips on
filters.

Regards
Peter

"R" wrote:

I need to write a program for construction estimating for my company.
Nothing fancy, justa little something to make my life easier. Since I
never know how many items I will need to lookup, I want to have the
userform update the excel cells as needed.
Here is the code I am trying to get to work. It looks at the previous
cell in the row for a match description. If it finds one, I need it to
lookup the value in the pricing database and return the value in the
cell.

=IF($K18="","",VLOOKUP($K18,'C:\Templates\pricing. xls'!OIGDB,3,FALSE))

example
Lets say in the description cell it finds "30 year shingles"
It then goes to the pricing database and findes "square foot" for
column 3 so will show "square foot" in the cell.
I hope this makes sense.

Thank you for any help.
Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
R R is offline
external usenet poster
 
Posts: 3
Default How to format a cell with VBA to return a value from a database?

Peter,
I do have VB. It has been quite a while since I did any programming
and have never done any programming for excel. I will search for
Debra's site and see if there is anything to help me there.
Thanks,
Rob

On Mon, 14 Mar 2005 19:47:01 -0800, "PeterAtherton"
wrote:

Rob

Do you need VB? I think you could use an advanced filter with your lookup
formula as a criterion.

Try the Help on filters and try debra dalgliesh's site for great tips on
filters.

Regards
Peter

"R" wrote:

I need to write a program for construction estimating for my company.
Nothing fancy, justa little something to make my life easier. Since I
never know how many items I will need to lookup, I want to have the
userform update the excel cells as needed.
Here is the code I am trying to get to work. It looks at the previous
cell in the row for a match description. If it finds one, I need it to
lookup the value in the pricing database and return the value in the
cell.

=IF($K18="","",VLOOKUP($K18,'C:\Templates\pricing. xls'!OIGDB,3,FALSE))

example
Lets say in the description cell it finds "30 year shingles"
It then goes to the pricing database and findes "square foot" for
column 3 so will show "square foot" in the cell.
I hope this makes sense.

Thank you for any help.
Rob


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to format a cell with VBA to return a value from a database?

The formula should work. What is your question?

--
Regards,
Tom Ogilvy



"R" wrote in message
...
I need to write a program for construction estimating for my company.
Nothing fancy, justa little something to make my life easier. Since I
never know how many items I will need to lookup, I want to have the
userform update the excel cells as needed.
Here is the code I am trying to get to work. It looks at the previous
cell in the row for a match description. If it finds one, I need it to
lookup the value in the pricing database and return the value in the
cell.

=IF($K18="","",VLOOKUP($K18,'C:\Templates\pricing. xls'!OIGDB,3,FALSE))

example
Lets say in the description cell it finds "30 year shingles"
It then goes to the pricing database and findes "square foot" for
column 3 so will show "square foot" in the cell.
I hope this makes sense.

Thank you for any help.
Rob



  #5   Report Post  
Posted to microsoft.public.excel.programming
R R is offline
external usenet poster
 
Posts: 3
Default How to format a cell with VBA to return a value from a database?

Here is the code I have once the command button is clicked:

Private Sub CommandButton1_Click()
ActiveCell.Value = UserForm1.ListBox1.Value
ActiveCell.Offset(0, 2).Select
ActiveCell.Formula =
"=IF($K21="","",VLOOKUP($K21,'C:\Templates\pricing .xls'!OIGDB,3,FALSE))"
End Sub

It still will not work. Not sure if it is a pathway error or using the
wrong formula attributes?

Rob

On Tue, 15 Mar 2005 08:10:39 -0500, "Tom Ogilvy"
wrote:

The formula should work. What is your question?


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
How do I format line return in a cell? Sue S Excel Discussion (Misc queries) 3 June 23rd 09 07:07 PM
Cell Format import from Database SpaceCoorDinator Excel Discussion (Misc queries) 1 May 7th 07 05:41 PM
format a cell to accept sentences... using return key lkconey Excel Discussion (Misc queries) 1 June 22nd 06 05:22 AM
Return MS-SQL database names to excel? No Name Excel Programming 2 October 7th 04 09:54 AM
How to read from a SQL Server table into Excel and use the Excel cell format as in the database Belinda Excel Programming 1 June 10th 04 04:45 PM


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