LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default HELP with inserting formula

Sub AddFormula()
Dim sh As Worksheet
Dim iLastRow As Long
Dim iLastCol As Long

For Each sh In ActiveWorkbook.Worksheets
iLastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
If iLastRow < 7 Then iLastRow = 7
iLastCol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column
If iLastCol < 2 Then iLastCol = 2
sh.Range("A4").FormulaR1C1 = "=COUNTA(R7C2:R" & iLastRow & "C" &
iLastCol & ")"
Next sh

End Sub



--
HTH

Bob Phillips

"Dragos" wrote in message
...
Hi Everyone,

I would like a Macro that Inserts the Following Formula into all of my

Excel
Sheet in the Cell "A4" Please.
The formula would be: A4 = COUNTA($B$7:last active row).
I want to mention that the last row varies.
I looked at the other discussion, but I didn't quite understand.
Thank you in advance,

Dragos

--
Dragos



 
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
Inserting Formula vcprabhu Excel Discussion (Misc queries) 1 April 6th 09 06:55 AM
inserting a formula dstiefe Excel Discussion (Misc queries) 6 August 10th 05 09:33 PM
Formula changes while inserting a row !!!! Sanjeev Unnikrishnan Excel Worksheet Functions 3 April 16th 05 02:45 PM
Inserting Formula Tom Ogilvy Excel Programming 4 July 14th 04 10:58 PM
inserting row...but the formula is not affected monika Excel Programming 2 April 19th 04 01:26 PM


All times are GMT +1. The time now is 03:50 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"