Display CountA Formula and Text String in a cell

H

henryonyeagbako

I have the following line of code that inserts into a particular cell
the count of the No. of asset records listed above it plus a text
string declaring " Assets in the selected period" plus it takes the
date value of two variables and formats them and places them in cell
along the text



rng.Formula = "=COUNTA(R[-4]C:R[-1]C)" & "&"" assets Aquired in the
selected period " & "" & Format$(first, "short date") & "" - "" &
Format$(last, "short date")




My problem is that this does not display as i would have liked the
dates are merely displayed as decimal numbers. I have changed the
format of the cell to correct this but that does not appear to alter
anything.

How do i get the cell to display the count for the cells display the
text message and the criteria range in the same cell
 
D

Dave Peterson

I'd use rng.formulaR1C1:

rng.FormulaR1C1 = "=COUNTA(R[-4]C:R[-1]C)" _
& " & " & """ assets Aquired in the selected period ""&" _
& """" & Format$(first, "short date") _
& " - " & Format$(last, "short date") & """"

I have the following line of code that inserts into a particular cell
the count of the No. of asset records listed above it plus a text
string declaring " Assets in the selected period" plus it takes the
date value of two variables and formats them and places them in cell
along the text

rng.Formula = "=COUNTA(R[-4]C:R[-1]C)" & "&"" assets Aquired in the
selected period " & "" & Format$(first, "short date") & "" - "" &
Format$(last, "short date")

My problem is that this does not display as i would have liked the
dates are merely displayed as decimal numbers. I have changed the
format of the cell to correct this but that does not appear to alter
anything.

How do i get the cell to display the count for the cells display the
text message and the criteria range in the same cell
 
H

henryonyeagbako

I'd use rng.formulaR1C1:

rng.FormulaR1C1 = "=COUNTA(R[-4]C:R[-1]C)" _
                    & " & " & """ assets Aquired in the selected period ""&" _
                    & """" & Format$(first, "short date") _
                    & " - " & Format$(last, "short date") & """"





I have the following line of code that inserts into a particular cell
the count of the No. of asset records listed above it plus a text
string declaring " Assets in the selected period" plus it takes the
date value of two variables and formats them and places them in cell
along the text
rng.Formula = "=COUNTA(R[-4]C:R[-1]C)" & "&"" assets Aquired in the
selected period " & "" & Format$(first, "short date") & "" - "" &
Format$(last, "short date")
My problem is that this does not display as i would have liked the
dates are merely displayed as decimal numbers. I have changed the
format of the cell to correct this but that does not appear to alter
anything.
How do i get the cell to display the count for the cells display the
text message and the  criteria range in the same cell

--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thanks for that it worked like a charm but now how do i get the
followiing to work also:-

rng.FormulaR1C1 = "=COUNTA(" & ActiveCell.Offset(-1, 0).Address & ":$A
$9)" & " & " & """ assets Aquired in the selected period ""&" & """" &
Format$(first, "short date") & " - " & Format$(last, "short date") &
""""
 
D

Dave Peterson

First, .address by itself won't give you an R1C1 reference style address. So in
this case, you don't want to use .formular1c1 (and $A$9 isn't an R1C1 address,
either).

So just try

Rng.Formula = "=COUNTA(" & ActiveCell.Offset(-1, 0).Address _
& ":$A$9)" & " & " _
& """ assets Aquired in the selected period ""&" _
& """" & Format$(First, "short date") _
& " - " & Format$(Last, "short date") & """"
 
H

henryonyeagbako

I'd use rng.formulaR1C1:

rng.FormulaR1C1 = "=COUNTA(R[-4]C:R[-1]C)" _
                    & " & " & """ assets Aquired in the selected period ""&" _
                    & """" & Format$(first, "short date") _
                    & " - " & Format$(last, "short date") & """"





I have the following line of code that inserts into a particular cell
the count of the No. of asset records listed above it plus a text
string declaring " Assets in the selected period" plus it takes the
date value of two variables and formats them and places them in cell
along the text
rng.Formula = "=COUNTA(R[-4]C:R[-1]C)" & "&"" assets Aquired in the
selected period " & "" & Format$(first, "short date") & "" - "" &
Format$(last, "short date")
My problem is that this does not display as i would have liked the
dates are merely displayed as decimal numbers. I have changed the
format of the cell to correct this but that does not appear to alter
anything.
How do i get the cell to display the count for the cells display the
text message and the  criteria range in the same cell

--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thank you very much three hours spent on this was driving me stir
crazy


Henry Onyeagbako
 

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

Top