Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Macro Drop Formula As Far As Required

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JB2010 - 24 May 2006 11:04 GMT
Hi

I am trying to make a shortcut, but the bit iam missing is quite an
important technical bit that will help me elsewhere.

basically, the shortcut puts a countif formula next to the active cell when
the macro is run e.g. in B2 next to the data in A2. i want it to countif for
the entire range of the data in column A. Then i want to dollar up that range
to lock it & drop  the formula down the entire length of column B where there
is data in column A.

The problem i have is that even with the 'relative preference' button
ticked, the code still makes reference to specific cells or range lenghts /
sizes. I want this macro to work on data sets of any type. does anyone know
how to make this more transferable.

here is the basic code so far

ActiveCell.Offset(1, 0).Range("A1").Select
   ActiveCell.FormulaR1C1 = "=COUNTIF(R2C8:R10208C8,RC[-1])"
   ActiveCell.Select
   Selection.AutoFill Destination:=ActiveCell.Range("A1:A10207")
   ActiveCell.Range("A1:A10207").Select
   ActiveCell.Columns("A:A").EntireColumn.Select
   Selection.Copy
   Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
       :=False, Transpose:=False
   Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
       SkipBlanks:=False, Transpose:=False
   ActiveCell.Offset(1, -1).Range("A1").Select
   Application.CutCopyMode = False
   ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.EntireColumn.AutoFit
End Sub

any help gratefully recieved. please contact for any further info

cheers

jb
Bernie Deitrick - 24 May 2006 13:34 GMT
jb,

Try the macro below.

HTH,
Bernie
MS Excel MVP

Sub TryNow()
With Range(ActiveCell, ActiveCell(1, 0).End(xlDown)(1, 2))
  .FormulaR1C1 = "=COUNTIF(C[-1]:C[-1],RC[-1])"
   .Value = .Value
   .EntireColumn.AutoFit
End With
End Sub

> Hi
>
[quoted text clipped - 36 lines]
>
> jb
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.