PDA

View Full Version : Solved: goto a specific cell and insert text using vb



ckelley1020
02-22-2011, 08:36 PM
i need to go to a specfic cell using a position I have grabbed using

lastrow = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count

totaltext = lastrow + 2

I need to put TEXT in that cell in column G. then put a formula (=count(H1:Htotaltext) in the next cell over in column H

how do I do that in VBA in excel? any help is appreciated

shrivallabha
02-22-2011, 09:20 PM
Welcome to VBAX.
To use formula:=
Range("G" & Totaltext).Formula = "=COUNT(H1:H" & TotalText & ")"
There is another method documented in VBA as FormulaR1C1 which uses column and rows' number reference. You may look into it, if you want to.

ckelley1020
02-22-2011, 09:34 PM
Thanks for the help. How do I place text such as "Totals" in the specific cell G:totaltext. Thanks for the one for the formula in the example you sent.:bow:

shrivallabha
02-22-2011, 09:38 PM
You need to tell VBA that the item being inserted is value. Like:
Range("G" & Totaltext).Value = "Total"
Be sure that you cover text with double quotes.

ckelley1020
02-23-2011, 07:31 AM
works great. thanks for the help:friends: