macro to insert formula in vba into two cells and copy down

Hi Experts (excel 2010)

Need a macro to insert the value 1 into cell b5 and then into cell b6 the formula =IF(A6="","",OFFSET(B4,1,0)+1) and into cell E5 the formula =IF(B5="","",CONCATENATE($E$3&" "&B5)) and copy the formula down based on the data in column A  range A5: last cell with value in column A…
route217JuniorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,
pls try

Sub macro()

lastRow = Range("A" & Cells.Rows.Count).End(xlUp).Row
Range("B5") = 1
Range("B6:B" & lastRow).Formula = "=IF(A6="""","""",OFFSET(B4,1,0)+1)"
Range("E5:E" & lastRow).Formula = "=IF(B5="""","""",CONCATENATE($E$3&"" ""&B5))"

End Sub

Open in new window

Regards
0
route217JuniorAuthor Commented:
Hi Rgonzo

Thanks for the feedback...but getting a compile error on last row = Range ( etc...
0
Rgonzo1971Commented:
lastrow  not  last row
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Rgonzo1971Commented:
See example
EE20151119.xlsm
0
route217JuniorAuthor Commented:
Rgonzo

Just seen ur code it's in thisworkbook...how can I call this to run with my other macros and I initially put this into a module.

As in the previous post it was a typo and I ment lastrow.
0
Rgonzo1971Commented:
You can put it in a normal module and try to run

but does my macro work in my file or not

Could you send a printscreen of your error
0
Rgonzo1971Commented:
then try
Sub macro()
Dim lastRow
lastRow = Range("A" & Cells.Rows.Count).End(xlUp).Row
Range("B5") = 1
Range("B6:B" & lastRow).Formula = "=IF(A6="""","""",OFFSET(B4,1,0)+1)"
Range("E5:E" & lastRow).Formula = "=IF(B5="""","""",CONCATENATE($E$3&"" ""&B5))"

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
route217JuniorAuthor Commented:
Rgonzo
No error eorks perfectly
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.