Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default No of rows as Range


Hi,
I need to write the macro that calculate a function that should be fil
all the rows with particular row.
i include the coding.

here the Range will be Range("G3:nRows")
the nRows is the No. of rows with used cells(with contents)
How to calculate the nRows??

code::

Sub CalculateTime()
'
' CalculateTime Macro
' Macro recorded 3/2/2006 by Shah
'
Dim nRows As Long

nRows = Application.ActiveSheet.UsedRange.Rows.Count
'
Range("G3").Select
'nRows = ActiveSheet.UsedRange.Rows.Count
'nRows = G2000

ActiveCell.FormulaR1C1 = "=IF(RC[-4]=R[-1]C[-4],R[-1]C+150,61366)"
Selection.AutoFill Destination:=Range("G3:nRows")
Type:=xlFillDefault
' Selection.AutoFill Destination:=Range("G3:G17750")
Type:=xlFillDefault
' Cells.Value
'Range("G3:G28884").Select

Range("G2").Select
End Su

--
zeesha
-----------------------------------------------------------------------
zeeshah's Profile: http://www.excelforum.com/member.php...fo&userid=2286
View this thread: http://www.excelforum.com/showthread.php?threadid=51813

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default No of rows as Range

Sub CalculateTime()
' CalculateTime Macro
' Macro recorded 3/2/2006 by Shah
Dim nRows As Long

nRows = Application.ActiveSheet.UsedRange.Rows.Count
'
Range("G3").Select
'nRows = ActiveSheet.UsedRange.Rows.Count
'nRows = G2000

ActiveCell.FormulaR1C1 = "=IF(RC[-4]=R[-1]C[-4],R[-1]C+150,61366)"
Selection.AutoFill Destination:=Range("G3:G" & nRows), _
Type:=xlFillDefault
' Selection.AutoFill Destination:=Range("G3:G17750"),
' Type:=xlFillDefault
' Cells.Value
'Range("G3:G28884").Select

Range("G2").Select
End Sub



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"zeeshah" wrote in
message ...

Hi,
I need to write the macro that calculate a function that should be fill
all the rows with particular row.
i include the coding.

here the Range will be Range("G3:nRows")
the nRows is the No. of rows with used cells(with contents)
How to calculate the nRows??

code::

Sub CalculateTime()
'
' CalculateTime Macro
' Macro recorded 3/2/2006 by Shah
'
Dim nRows As Long

nRows = Application.ActiveSheet.UsedRange.Rows.Count
'
Range("G3").Select
'nRows = ActiveSheet.UsedRange.Rows.Count
'nRows = G2000

ActiveCell.FormulaR1C1 = "=IF(RC[-4]=R[-1]C[-4],R[-1]C+150,61366)"
Selection.AutoFill Destination:=Range("G3:nRows"),
Type:=xlFillDefault
' Selection.AutoFill Destination:=Range("G3:G17750"),
Type:=xlFillDefault
' Cells.Value
'Range("G3:G28884").Select

Range("G2").Select
End Sub


--
zeeshah
------------------------------------------------------------------------
zeeshah's Profile:

http://www.excelforum.com/member.php...o&userid=22867
View this thread: http://www.excelforum.com/showthread...hreadid=518138



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
How can change range to select active rows instead of :=Range("S10 ldiaz Excel Discussion (Misc queries) 7 August 29th 08 03:52 PM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
Used Rows Range? HotRod Excel Programming 6 November 7th 05 06:07 PM
Rows in a Range John Smith[_12_] Excel Programming 3 November 14th 04 01:56 PM
group rows in a range based on criteria from another range (vba) Andy Excel Programming 2 April 28th 04 03:26 AM


All times are GMT +1. The time now is 06:43 PM.

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"