Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Stuck with script - Help Please

Hi All, i have the script below that works fine with one exception and
that is that it puts an "#N/A" in the cell and i would like it to be
blank.

Sub LookupBat()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Dim sFormula As Integer
Range("A4").Select
' UpdateProgressH = 0
With Workbooks(myfileNameBat).Worksheets(SheetNameBat)
Set myLookUpRng = .Range("C:U")
End With
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
NumRows = LastRow - 3
For i = 4 To LastRow
If Cells(i, "I") = "" Then
Cells(i, "I").Value = Application.VLookUp(Cells(i,
"A").Value, _
myLookUpRng, 19, 0)
Cells(i, "I").Value = Cells(i, "I").Value
End If
UpdateProgressH (i - 3) / NumRows
Next i
Unload UserForm2
Range("A4").Select
' InsPriceDiff
End Sub


Thanks in advance,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stuck with script - Help Please

Sub LookupBat()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Dim sFormula As Integer
Range("A4").Select
' UpdateProgressH = 0
With Workbooks(myfileNameBat).Worksheets(SheetNameBat)
Set myLookUpRng = .Range("C:U")
End With
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
NumRows = LastRow - 3
For i = 4 To LastRow
With Cells(i, "I")
If .Value = "" Then
.Value = Application.VLookUp(.Value, _
myLookUpRng, 19, 0)
If IsError(.Value) Then
.Value = ""
Else
.Value = .Value
End If
End If
End With
UpdateProgressH (i - 3) / NumRows
Next i
Unload UserForm2
Range("A4").Select
' InsPriceDiff
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Les Stout" wrote in message
...
Hi All, i have the script below that works fine with one exception and
that is that it puts an "#N/A" in the cell and i would like it to be
blank.

Sub LookupBat()

Dim myLookUpRng As Range
Dim i As Long
Dim NumRows As Long
Dim LastRow As Long
Dim sFormula As Integer
Range("A4").Select
' UpdateProgressH = 0
With Workbooks(myfileNameBat).Worksheets(SheetNameBat)
Set myLookUpRng = .Range("C:U")
End With
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
NumRows = LastRow - 3
For i = 4 To LastRow
If Cells(i, "I") = "" Then
Cells(i, "I").Value = Application.VLookUp(Cells(i,
"A").Value, _
myLookUpRng, 19, 0)
Cells(i, "I").Value = Cells(i, "I").Value
End If
UpdateProgressH (i - 3) / NumRows
Next i
Unload UserForm2
Range("A4").Select
' InsPriceDiff
End Sub


Thanks in advance,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Stuck with script - Help Please

Sorry a correction to that it is putting "#NAME?" into the cell now, but
not overwriting the existing info.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Stuck with script - Help Please

Thanks a million Bob, have a great evening.

best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Stuck with script - Help Please

Does the other solution not work regardless?

Actually, this means that the formula has a mis-spelt function, or refers to
an object (worksheet, name) that does not exist.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Les Stout" wrote in message
...
Sorry a correction to that it is putting "#NAME?" into the cell now, but
not overwriting the existing info.

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Stuck with script - Help Please

Hi Bob, it works great, thanks for all your input.

best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.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
I am stuck Ujpest Excel Worksheet Functions 1 March 6th 10 12:19 AM
Im stuck in VB! D[_6_] Excel Programming 5 August 11th 04 12:38 AM
Ok now im stuck Jonathan Excel Programming 2 June 29th 04 01:06 PM
Still stuck Adrian Excel Programming 5 May 21st 04 03:56 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"