Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default set formula by Macro

Hi,

I want to set formula -COUNTIF() in cell.I am trying to do this like --
--------------------------------------------------------------------------------------------------
Private Sub Copyformula_Click()

Dim i As Integer

If Not Range("AJ21 : AJ85").HasFormula Then

For i = 21 To 85

With ActiveSheet

.Range("AJ" + i).Cells.Formula = "=COUNTIF(D17:D2000,"
& Range("AI" + i).Text & ")"


End With

Next i

End If

End Sub
-------------------------------------------------------------------------------------------------------
I am getting error as "Type mismatch". Here I am exactly trying to
implement the logic to assign the formula in each cell.The formula will
count the presence of the text of that range.

Plz.. help me with the correct code.

Thanks and Regards,
Nil

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 125
Default set formula by Macro

Just a little tweak, you were trying to add a number 'i' to letters of your
range e.g.(AI+21)
Change the '+' to '$' and your good.

" wrote:

Hi,

I want to set formula -COUNTIF() in cell.I am trying to do this like --
--------------------------------------------------------------------------------------------------
Private Sub Copyformula_Click()

Dim i As Integer

If Not Range("AJ21 : AJ85").HasFormula Then

For i = 21 To 85

With ActiveSheet

.Range("AJ" + i).Cells.Formula = "=COUNTIF(D17:D2000,"
& Range("AI" + i).Text & ")"


End With

Next i

End If

End Sub
-------------------------------------------------------------------------------------------------------
I am getting error as "Type mismatch". Here I am exactly trying to
implement the logic to assign the formula in each cell.The formula will
count the presence of the text of that range.

Plz.. help me with the correct code.

Thanks and Regards,
Nil


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default set formula by Macro

.Range("J" & i).Formula = "=COUNTIF(D17:D2000,""" & _
.Range("I" & i).Text & """)"



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"John Bundy" wrote in message
...
Just a little tweak, you were trying to add a number 'i' to letters of

your
range e.g.(AI+21)
Change the '+' to '$' and your good.

" wrote:

Hi,

I want to set formula -COUNTIF() in cell.I am trying to do this like --


--------------------------------------------------------------------------

------------------------
Private Sub Copyformula_Click()

Dim i As Integer

If Not Range("AJ21 : AJ85").HasFormula Then

For i = 21 To 85

With ActiveSheet

.Range("AJ" + i).Cells.Formula = "=COUNTIF(D17:D2000,"
& Range("AI" + i).Text & ")"


End With

Next i

End If

End Sub


--------------------------------------------------------------------------

-----------------------------
I am getting error as "Type mismatch". Here I am exactly trying to
implement the logic to assign the formula in each cell.The formula will
count the presence of the text of that range.

Plz.. help me with the correct code.

Thanks and Regards,
Nil




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 125
Default set formula by Macro

Sorry my aim is off, change to & not $

"John Bundy" wrote:

Just a little tweak, you were trying to add a number 'i' to letters of your
range e.g.(AI+21)
Change the '+' to '$' and your good.

" wrote:

Hi,

I want to set formula -COUNTIF() in cell.I am trying to do this like --
--------------------------------------------------------------------------------------------------
Private Sub Copyformula_Click()

Dim i As Integer

If Not Range("AJ21 : AJ85").HasFormula Then

For i = 21 To 85

With ActiveSheet

.Range("AJ" + i).Cells.Formula = "=COUNTIF(D17:D2000,"
& Range("AI" + i).Text & ")"


End With

Next i

End If

End Sub
-------------------------------------------------------------------------------------------------------
I am getting error as "Type mismatch". Here I am exactly trying to
implement the logic to assign the formula in each cell.The formula will
count the presence of the text of that range.

Plz.. help me with the correct code.

Thanks and Regards,
Nil


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
Find value in array Brook6 Excel Worksheet Functions 26 January 30th 07 09:40 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Formula for current month minus one = Quarter number in a macro. Pank Excel Discussion (Misc queries) 11 June 22nd 05 02:47 PM
Formula checking multiple worksheets sonic-the-mouse Excel Worksheet Functions 2 June 5th 05 07:48 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


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