Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Reference relative to activecell

I'm working with Excel 2003 and need to populate a worksheet
programmatically. I can't figure out the correct syntax and need some
help.

I need to add a row count at the end of each row but won't know how
many rows and columns have been filled. I can get the ActiveCell to
the rightmost column and get the last row without much trouble but
that's about as far as I am getting. The .Row property returns the
row number of the last row but .Column returns a number not a letter.
The .Address property returns the correct information but includes the
column and row together. Breaking that string apart to get the column
seems awkward. (It could be $F$7 or $AT$199)

Once I've selected the correct column and row what syntax will allow
me to add a formula to that column? I'm trying to work with something
like:

Range(CurrentColumn3:CurrentColumnLastRow)
.Formula = "=COUNTIF(C3:CurrentColumn3, "X")

I can't figure out the syntax and would appreciate help.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default Reference relative to activecell

Rather than worrying about selecting the right cell you should start with
the starting point which is I gather C3.

Sub a()
Dim RowCount As Integer
Dim ColCount As Integer
With Range("C3")
RowCount = Range(.Cells(1), .End(xlDown)).Rows.Count
ColCount = Range(.Cells(1), .End(xlToRight)).Columns.Count
.Offset(0, ColCount).Resize(RowCount).FormulaR1C1 = _
"=countif(RC[-" & ColCount & "]:RC[-1],""x"")"
End With
End Sub

You can replace the C3 with any cell and it should work fine.

--
Jim
"Arch" wrote in message
...
I'm working with Excel 2003 and need to populate a worksheet
programmatically. I can't figure out the correct syntax and need some
help.

I need to add a row count at the end of each row but won't know how
many rows and columns have been filled. I can get the ActiveCell to
the rightmost column and get the last row without much trouble but
that's about as far as I am getting. The .Row property returns the
row number of the last row but .Column returns a number not a letter.
The .Address property returns the correct information but includes the
column and row together. Breaking that string apart to get the column
seems awkward. (It could be $F$7 or $AT$199)

Once I've selected the correct column and row what syntax will allow
me to add a formula to that column? I'm trying to work with something
like:

Range(CurrentColumn3:CurrentColumnLastRow)
.Formula = "=COUNTIF(C3:CurrentColumn3, "X")

I can't figure out the syntax and would appreciate help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
Activecell Reference in Macro Jim May Excel Programming 2 August 9th 06 07:18 PM
Specifying range relative to activecell in macro KellyInCali Excel Programming 6 November 7th 05 11:42 PM
using variable inside activeCell reference call dabith[_7_] Excel Programming 2 June 19th 04 08:02 PM
selecting a cell relative to activecell in an excel macro Zogann Excel Programming 1 October 17th 03 12:20 PM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"