Using the Lastrow variable in a Count/Countif formula

  • Thread starter Thread starter John
  • Start date Start date
J

John

Here's what I'm trying to do:

1. Find the lastrow with data in it:

bb = Cells(Rows.Count, "B").End(xlUp).Row (OK)

2. Next use variable bb as part of a COUNT formula in cell D1:

Range("D1").Formula = "=COUNT("M" & 5 & ":M" & bb)"

The error I receive is:

Compile error -- expected End of Statement

Please help

Thanks
John
 
maybe:

Range("D1").Formula = "=COUNT(""M5:M" & bb & """)"
'or
Range("D1").Formula = "=COUNT(""M" & 5 & ":M" & bb & """)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top