Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I'm trying to run VBA to put formula into a cell

Cells(10, 4).Formula = "=Max(H &""FirstRow""&,H &""LastRow""&)"

I get Run-time error '1004':


Thank you for your help

What I have tried:

I tried this

Cells(10, 4).Formula = "=Max(H2,H14)"

it works fine.
Posted
Updated 23-Feb-18 4:53am

Quote:
VB
Cells(10, 4).Formula = "=Max(H &""FirstRow""&,H &""LastRow""&)"

I get Run-time error '1004':

Because quotes are misplaced.
Try
VB
Cells(10, 4).Formula = "=Max(H" & FirstRow & ",H" & LastRow & ")"
 
Share this answer
 
Comments
Member 13693055 23-Feb-18 12:08pm    
Thank you very much
Maybe that will bring you some clues about it:
VBA Tutorial: Find the Last Row, Column, or Cell on a Sheet[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900