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

Hi. Is there a way to have excel scan a column, and if a cell in column A
is not blank, then insert a Vlookup formula in the same row, column C. If
the cell in column A is blank, then do nothing and move to the next cell.
Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Program VLookup

somethinglike

Sub Macro1()
Dim cl As Range
For Each cl In Range("A:A")
If Not IsEmpty(cl) Then
ActiveCell.Offset(0, 2).Formula =
Application.Worksheetfunction.VLookup(....)
End If
Next cl
End Sub


http://www.excel-ant.co.uk

Steph wrote:
Hi. Is there a way to have excel scan a column, and if a cell in column A
is not blank, then insert a Vlookup formula in the same row, column C. If
the cell in column A is blank, then do nothing and move to the next cell.
Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Program VLookup

One more--if the cells in column A are filled with constants--not formulas.

Option Explicit
Sub testme01()

Dim myRng As Range

With Worksheets("sheet1")
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("A:A").Cells.SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0

If myRng Is Nothing Then
'do nothing
Else
myRng.Offset(0, 2).FormulaR1C1 _
= "=vlookup(rc[-2],sheet2!c1:c5,2,false)"
End If
End With

End Sub

After you run it, take a look at one of the formulas in the cells. You'll see
how that R1C1 stuff gets translated back to A1 reference style.



Steph wrote:

Hi. Is there a way to have excel scan a column, and if a cell in column A
is not blank, then insert a Vlookup formula in the same row, column C. If
the cell in column A is blank, then do nothing and move to the next cell.
Thanks!


--

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
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
Which program? Dear Sir Excel Discussion (Misc queries) 4 January 14th 07 07:27 PM
My program SM Excel Worksheet Functions 2 October 22nd 05 04:52 AM
using VLookUp in a VBA program nano_electronix Excel Programming 17 July 30th 04 03:59 PM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


All times are GMT +1. The time now is 04:27 PM.

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"