#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default lookup vba

I am new to macros and trying to make things as simple as possible, I have
this code which enters a formula into the cell to do a look up but the cell
then needs to be left unprotected but i get the error bit in the corner of
the cell. How could i do this in VBA code?

Thank you


Sub AutoFillSG()
ActiveCell.FormulaR1C1 = _

"=IF(RC[-2]="""","""",IF(R[-13]C[-2]=""WBM"",LOOKUP(R[11]C[-2],Densities!C[-5],Densities!C[-4]),LOOKUP(RC[-2],Densities!C[-1],Densities!C)))"
Range("H21").Select
Selection.AutoFill Destination:=Range("H21:H39"), Type:=xlFillDefault
Range("H21:H39").Select
Range("H21").Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default lookup vba

I wasdn't getting any errors with excel 2003. I simplified the macro and
still din't have any problems.

Sub AutoFillSG()
Range("H21").FormulaR1C1 = _
"=IF(RC[-2]="""",""""," & _
"IF(R[-13]C[-2]=""WBM""," & _
"LOOKUP(R[11]C[-2],Densities!C[-5],Densities!C[-4])," & _
"LOOKUP(RC[-2],Densities!C[-1],Densities!C)))"

Range("H21").AutoFill Destination:=Range("H21:H39"), _
Type:=xlFillDefault
End Sub

"Miree" wrote:

I am new to macros and trying to make things as simple as possible, I have
this code which enters a formula into the cell to do a look up but the cell
then needs to be left unprotected but i get the error bit in the corner of
the cell. How could i do this in VBA code?

Thank you


Sub AutoFillSG()
ActiveCell.FormulaR1C1 = _

"=IF(RC[-2]="""","""",IF(R[-13]C[-2]=""WBM"",LOOKUP(R[11]C[-2],Densities!C[-5],Densities!C[-4]),LOOKUP(RC[-2],Densities!C[-1],Densities!C)))"
Range("H21").Select
Selection.AutoFill Destination:=Range("H21:H39"), Type:=xlFillDefault
Range("H21:H39").Select
Range("H21").Select
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default lookup vba

You probably need to adjust the error checking, try with just the Unlocked
first:
Sub Err_Check()
With Application.ErrorCheckingOptions
..TextDate = False
..NumberAsText = False
..UnlockedFormulaCells = False
End With
End Sub
__________________
Regards,
The Code Cage Team
http://www.thecodecage.com/forumz/

"Miree" wrote:

I am new to macros and trying to make things as simple as possible, I have
this code which enters a formula into the cell to do a look up but the cell
then needs to be left unprotected but i get the error bit in the corner of
the cell. How could i do this in VBA code?

Thank you


Sub AutoFillSG()
ActiveCell.FormulaR1C1 = _

"=IF(RC[-2]="""","""",IF(R[-13]C[-2]=""WBM"",LOOKUP(R[11]C[-2],Densities!C[-5],Densities!C[-4]),LOOKUP(RC[-2],Densities!C[-1],Densities!C)))"
Range("H21").Select
Selection.AutoFill Destination:=Range("H21:H39"), Type:=xlFillDefault
Range("H21:H39").Select
Range("H21").Select
End Sub

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
lookup help. lookup result based on data in 2 columns lcc Excel Worksheet Functions 3 April 6th 10 01:20 PM
LOOKUP FUNCTION? (LOOKUP VALUE BEING A TIME RENERATED FROM A FORMU JCC Excel Discussion (Misc queries) 5 June 26th 09 09:15 PM
Get Cell Address From Lookup (Alternative to Lookup) ryguy7272 Excel Worksheet Functions 12 September 28th 07 10:36 PM
Join 2 Lists - Lookup value in 1 list & use result in 2nd lookup JBush Excel Worksheet Functions 3 January 3rd 07 11:14 PM
Sumproduct - Condition based on lookup of a Lookup Hari Excel Discussion (Misc queries) 12 May 31st 06 09:28 AM


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