Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Excel/VBA Programming

Thank you I don't know what I was thinking that really helped me alot though.
It's been over a year since I've programmed let alone trying to figure out
how to program in excel/vb. I think I will also need an index function to
store the value in too instead of storing it in a whole range.

"Don Guillett" wrote:

1st. You can't ask if a whole range = "CCS" without a loop or a countif.

--
Don Guillett
SalesAid Software

"HeatherO" wrote in message
...
Thank you that did answer some of my vlookup questions. I have one more I
have changed around the code to this:
Workbooks("Auto Model Grid").Worksheets("Sheet1").Activate
With ActiveSheet

If .Range("L2:L55") = "CCS" Then
If ccsfile = "yes" Then
.Range("N2:N55").Value =
Application.WorksheetFunction.VLookup("ccswrkbk",
Sheets("SMART").Range("$A$2:$H$82"), 7, 0)
End If

ElseIf .Range("L2:L55") = "DCS" Then
If dcsfile = "yes" Then
.Range("N2:N55").Value =
Application.WorksheetFunction.VLookup("dcswrkbk",
Sheets("SMART").Range("$A$2:$H$82"), 7, 0)
End If
End If
End With

My problem is that the if .range("L2:L55") I get an error on saying it is
out of context. Is this because of the data in that range or does it not
understand what range to look at because I thought with the activesheet
command and with it would be working with that sheet regardless. Thanks

for
your help in advance.
Heather
"Dick Kusleika" wrote:


"GHoward" wrote in message
...

Posted to Excel Programming

Title: Using VLOOKUP in VBA

Part of a VBA program I wrote for an Excel workbook uses VLOOKUP to
read a value from a list on one sheet and enters that value in a cell
on another sheet. After the value is entered, I use the PrintOut
method to print the sheet. The code runs fine until it hits a value
that is not in the list. When it does, the error value is not entered
into the sheet and the program stops, no error message. Here is the
code:

If


Application.WorksheetFunction.IsNA(Application.Wor ksheetFunction.VLookup(cnn
,
_
Sheets("Custname").Range("CN"), 4, False)) = True Then
cname = "--"
Else
cname = Application.WorksheetFunction.VLookup(cnn,
Sheets("Custname").Range("CN"), 4, False)
End If

I want it to enter two dashes if it gets an error, but instead of

doing
that, the program quits. What am I doing wrong? Thanks


Nothing, the WorksheetFunction method just doesn't handle errors very

well.
If you leave the WorksheetFunction part out, you can test for an error.

See
here for details

http://www.dicks-blog.com/excel/2004...rksheetfu.html

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com






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
Excel Programming danjordan2000 Excel Discussion (Misc queries) 1 November 17th 08 01:20 PM
ADO programming in Excel-VBA CLamar Excel Discussion (Misc queries) 1 May 31st 06 02:45 PM
Excel Programming Geoff D'Arcy Excel Programming 2 November 1st 04 12:07 PM
Excel Programming Help Jason Excel Programming 1 July 7th 04 02:50 AM
Excel programming seang Excel Programming 1 February 18th 04 07:03 AM


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