Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Add COUNTIF TO USERFORM TEXTBOX

Apologies, I am not any sort fo expert in Visual Basic. I have a
userform which has a number of text boxes, on activation of the
userform I want the text boxes to calculate a COUNTIF based on the
worksheet that is open.

i.e

Form

Bananas [TEXT BOX]
Apples [TEXT BOX]
etc
etc

and the form code has something like the idea of (sorry no idea about
syntax)

set ws = active.worksheet
Bananas = Applicaiton.WorksheetFunction.COUNTIF("ws"!$A$9:$A L
$44,"Bananas")

Can anyone help please?

Cheers

Rich
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,533
Default Add COUNTIF TO USERFORM TEXTBOX

Hi Rick

Insert this code in the codesheet for the userform, where TextBox1 is the
name of the textbox.

Private Sub UserForm_Initialize()
Set ws = ActiveSheet
Me.TextBox1 = Application.WorksheetFunction. _
CountIf(ws.Range("$A$9:$AL$44"), "Bananas")
End Sub

Hopes this helps.
....
Per

"Richhall" skrev i meddelelsen
...
Apologies, I am not any sort fo expert in Visual Basic. I have a
userform which has a number of text boxes, on activation of the
userform I want the text boxes to calculate a COUNTIF based on the
worksheet that is open.

i.e

Form

Bananas [TEXT BOX]
Apples [TEXT BOX]
etc
etc

and the form code has something like the idea of (sorry no idea about
syntax)

set ws = active.worksheet
Bananas = Applicaiton.WorksheetFunction.COUNTIF("ws"!$A$9:$A L
$44,"Bananas")

Can anyone help please?

Cheers

Rich


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Add COUNTIF TO USERFORM TEXTBOX

Brilliant thank you

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Add COUNTIF TO USERFORM TEXTBOX

How would I add numerous calculations from countifs in a different
range? i,e


Bananas + Apples.

Me.TextBox1 = Application.WorksheetFunction. _
CountIf(ws.Range("$A$9:$AL$44"), "Bananas") +
Application.WorksheetFunction. _
CountIf(ws.Range("$B$9:$D$44"), "Apples")

????
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Add COUNTIF TO USERFORM TEXTBOX

Sorry, Have seen this works by trying, I'd missed some brackets out.
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
Date Format for Userform TextBox John Calder New Users to Excel 4 July 29th 09 10:19 PM
Userform textbox number formats PhilM Excel Discussion (Misc queries) 2 June 7th 06 11:08 AM
Userform with 5 textbox and 1 needs to refresh to have total funkymonkUK Excel Discussion (Misc queries) 1 February 17th 05 01:45 AM
UserForm TextBox/ComboBox question grasping@straws Excel Discussion (Misc queries) 1 February 2nd 05 11:14 AM
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM


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