VBA code to fill formula

sdfchu

New Member
Joined
Oct 17, 2018
Messages
5
Hi,
I am working on a macro where I want column A to drag and drop a formula when i run the macro, but when I run code below i get this error "Run-time '1004': Method 'Range' of object'_Global' failed. I am learning VBA as i go so i will really appreciate help with code below.

Code:
Range("A1").Select
Range("a2:a" & LastRowColumnA).Formula = "=IF(RC[16]=""not in Smart List"",""not in Smart List"",IF(ISNUMBER(SEARCH(""dead"",RC[14])),""Failed to scan"",IF(RC[7]=""NULL"",""NULL"",IF(ISNUMBER(SEARCH("" log into"",RC[13])),""OK"",IF(ISNUMBER(SEARCH(""was able to log"",RC[17])),""OK"",IF(ISNUMBER(SEARCH("" log into"",RC[10])),""OK"",IF(ISNUMBER(SEARCH("" checks : no"",RC[11])" & _
        "entication Failed"",""OK"")))))))"

Thank You,
 
Last edited by a moderator:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi. First things first you cant use R1C1 references with .Formula, you have to use .FormulaR1C1 = etc etc. Try that.
 
Upvote 0
Hi & welcome to the board
Another thing, what is the value of "LastRowColumnA"?
 
Last edited:
Upvote 0
Also some of the formula is chopped off. It was a bug in VBA for years and years with long formulas. Paste the formula that you have in A2.
 
Upvote 0
I think you are also missing a bracket in the below where i have highlighted a bracket in red


IF(ISNUMBER(SEARCH("" checks : no"",RC[11]))" & _
 
Upvote 0
I think you are also missing a bracket in the below where i have highlighted a bracket in red


IF(ISNUMBER(SEARCH("" checks : no"",RC[11]))" & _

Thats the bug i spoke about barry. It chops at the line feed when recording a long formula. It doesnt do it with my 365 2016 version anymore.
 
Upvote 0
Also some of the formula is chopped off. It was a bug in VBA for years and years with long formulas. Paste the formula that you have in A2.


formula in A2 is as below

=IF(Q1314="not in Smart List","not in Smart List",IF(ISNUMBER(SEARCH("dead",O1314)),"Failed to scan",IF(H1314="NULL","NULL",IF(ISNUMBER(SEARCH("log into",N1314)),"OK",IF(ISNUMBER(SEARCH("was able to log",R1314)),"OK",IF(ISNUMBER(SEARCH("log into",K1314)),"OK",IF(ISNUMBER(SEARCH("checks : no",L1314)),"Authentication Failed","OK")))))))
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top