Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default retrieving cell reference data

I am new to this so pardon my ignorance. I am trying to write a short macro
but first I need to obtain the row and column info of the cell that is
currently selected. How do I do so?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default retrieving cell reference data

If you are writing a SUB then

ActiveCell

If you want to create a UDF (User Define function) like you would use on a
worksheet then You will pas the cell(s) that you are using in the function

=MySum(A1:b10_


function MySum(target as range)
MySum = 0
for each cell in target
MySum = MySum + cell.value
next cell

end function


"thomas donino" wrote:

I am new to this so pardon my ignorance. I am trying to write a short macro
but first I need to obtain the row and column info of the cell that is
currently selected. How do I do so?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default retrieving cell reference data

msgbox activecell.row & vblf & activecell.column



thomas donino wrote:

I am new to this so pardon my ignorance. I am trying to write a short macro
but first I need to obtain the row and column info of the cell that is
currently selected. How do I do so?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default retrieving cell reference data

I am trying to total Z30 for example once data starts getting entered into
row30. For example once the user starts enter data into the cells in row 30 ,
Z30 begins to update the running total of all data entered in row 30

"Joel" wrote:

If you are writing a SUB then

ActiveCell

If you want to create a UDF (User Define function) like you would use on a
worksheet then You will pas the cell(s) that you are using in the function

=MySum(A1:b10_


function MySum(target as range)
MySum = 0
for each cell in target
MySum = MySum + cell.value
next cell

end function


"thomas donino" wrote:

I am new to this so pardon my ignorance. I am trying to write a short macro
but first I need to obtain the row and column info of the cell that is
currently selected. How do I do so?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default retrieving cell reference data

The a a few approaches in doing this

1) Put a formula on the worksheet

=Sum(A1:Y1)

Then copy done the worksheet. The only problem if you keep on adding new
rows you need to copy done the entire column (to 65536) and you will have
zeroes in rows without data

2) Similar to 1 above except put an if statement. The only problem with the
IF is cell in not consider empty when no data is in the row.

=if(countA(A1:Y1)0,Sum(A1:Y1),"")


3) Use a worksheet change function to add the formula when data is entered
in the cell

Sub worksheet_change(ByVal target As Range)

For Each cell In target
If Application.Intersect(target, Columns("Z")) Is Nothing Then
Range("Z" & target.Row).Formula = _
"=Sum(A" & target.Row & ":Y" & target.Row & ")"
End If
Next


End Sub


4) If you don't want a formula in the cell instead a real number

Sub worksheet_change(ByVal target As Range)

For Each cell In target
If Application.Intersect(target, Columns("Z")) Is Nothing Then
Range("Z" & target.Row).Formula = _
Evaluate("Sum(A" & target.Row & ":Y" & target.Row & ")")

End If
Next

End Sub






"thomas donino" wrote:

I am trying to total Z30 for example once data starts getting entered into
row30. For example once the user starts enter data into the cells in row 30 ,
Z30 begins to update the running total of all data entered in row 30

"Joel" wrote:

If you are writing a SUB then

ActiveCell

If you want to create a UDF (User Define function) like you would use on a
worksheet then You will pas the cell(s) that you are using in the function

=MySum(A1:b10_


function MySum(target as range)
MySum = 0
for each cell in target
MySum = MySum + cell.value
next cell

end function


"thomas donino" wrote:

I am new to this so pardon my ignorance. I am trying to write a short macro
but first I need to obtain the row and column info of the cell that is
currently selected. How do I do so?

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
Data Retrieving eggpap[_33_] Excel Programming 0 May 9th 09 09:14 AM
Retrieving Data: Speed of beating down rows vs retrieving from array? (PeteCresswell) Excel Programming 2 July 9th 07 03:30 PM
Retrieving Cell Data From Variable Files DJ Pomeroy Excel Worksheet Functions 3 April 24th 07 08:32 PM
retrieving data Jess Excel Worksheet Functions 1 February 13th 07 04:54 PM
Retrieving a Reference automandc Excel Worksheet Functions 4 May 6th 05 03:02 PM


All times are GMT +1. The time now is 01:19 AM.

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

About Us

"It's about Microsoft Excel"