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

On Error Resume I want the return to be " " ,so I have the code below, but it
doesn't return " " , instead it returns the value of the cell before it.
I've tried IsEmpty() rather than VariantType.Empty, but it doesn't recogize
that in Visual Studio 2005, it says IsEmpty() is no longer supported. Any
ideas on what I can do to get it to return " " instead of the value of tmp
that is stored from the previous loop?

Dim tmp As VariantType

For i = 3 To lastRow Step 1

On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value,
oApp.Range("A1:J" & lastRow).Value, 10, False)
On Error GoTo 0

If tmp = VariantType.Empty Then
LCV.Range("L" & i).Value = " "
Else : LCV.Range("L" & i).Value = tmp
End If

Next i
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VariantType.Empty error

In VBA, you could use:

tmp = Empty
to set it back to empty.

If that doesn't work in VS, maybe you could do:

Dim tmp as variant' VariantType???
dim myStr as string 'ok in VS????

mystr = "no value found in the search!!!" 'some unique string

For i = 3 To lastRow Step 1

tmp = mystr
On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value, _
oApp.Range("A1:J" & lastRow).Value, 10, False)
On Error GoTo 0

If tmp = mystr then
tmp = " " 'I'd use "", don't include that space character
end if

LCV.Range("L" & i).Value = tmp

Next i


NewToVB wrote:

On Error Resume I want the return to be " " ,so I have the code below, but it
doesn't return " " , instead it returns the value of the cell before it.
I've tried IsEmpty() rather than VariantType.Empty, but it doesn't recogize
that in Visual Studio 2005, it says IsEmpty() is no longer supported. Any
ideas on what I can do to get it to return " " instead of the value of tmp
that is stored from the previous loop?

Dim tmp As VariantType

For i = 3 To lastRow Step 1

On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value,
oApp.Range("A1:J" & lastRow).Value, 10, False)
On Error GoTo 0

If tmp = VariantType.Empty Then
LCV.Range("L" & i).Value = " "
Else : LCV.Range("L" & i).Value = tmp
End If

Next i


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default VariantType.Empty error

I tried it without the space earlier and it didn't work. But I'll try it
this way and see if it works. Yeah, VariantType is what I have to us in VS.
And there is a property called VariantType.Empty....but it didn't seem to
work like IsEmpty. Thanks for the help. I'll let you know how it goes!

"Dave Peterson" wrote:

In VBA, you could use:

tmp = Empty
to set it back to empty.

If that doesn't work in VS, maybe you could do:

Dim tmp as variant' VariantType???
dim myStr as string 'ok in VS????

mystr = "no value found in the search!!!" 'some unique string

For i = 3 To lastRow Step 1

tmp = mystr
On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value, _
oApp.Range("A1:J" & lastRow).Value, 10, False)
On Error GoTo 0

If tmp = mystr then
tmp = " " 'I'd use "", don't include that space character
end if

LCV.Range("L" & i).Value = tmp

Next i


NewToVB wrote:

On Error Resume I want the return to be " " ,so I have the code below, but it
doesn't return " " , instead it returns the value of the cell before it.
I've tried IsEmpty() rather than VariantType.Empty, but it doesn't recogize
that in Visual Studio 2005, it says IsEmpty() is no longer supported. Any
ideas on what I can do to get it to return " " instead of the value of tmp
that is stored from the previous loop?

Dim tmp As VariantType

For i = 3 To lastRow Step 1

On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value,
oApp.Range("A1:J" & lastRow).Value, 10, False)
On Error GoTo 0

If tmp = VariantType.Empty Then
LCV.Range("L" & i).Value = " "
Else : LCV.Range("L" & i).Value = tmp
End If

Next i


--

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
#VALUE error with empty cells adriver Excel Discussion (Misc queries) 1 October 9th 09 10:16 PM
#Empty error Alan P Excel Discussion (Misc queries) 2 October 5th 06 02:37 PM
Error (empty list box)? Ctech[_125_] Excel Programming 2 March 22nd 06 02:34 PM
error: cannot empty the Clipboard Jane New Users to Excel 0 December 29th 05 07:59 PM


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