Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Sum and Counta function in Listbox for UserForm

Hi,

I design the Userform for the Query, its working very nice, in this
form I can get the filtered data in the listbox.

I need two extra textbox in my userform to display the total number of
Records and the Sum of the total amount. how to make this I dont know.
I put the formula in the worksheet, and connect to the Userform with
textbox, upon loading the userform its deleting the formula in the
worksheet.

Pls help me out how to make this procedure.

Waiting for reply.

With Best Regard.

Pls fine below my procedure in the UserForm.


Syed Shahzad Zafar
Madinah

Option Explicit

Private Sub UserForm_Initialize()

HideTitleBar Me ' this command is link to Macro: Hide_TitleBar of
userform

Sheets("DailyIssue").Select
Range("A1").Activate

StartDate = ""
EndDate = ""
MaterialName = ""
CoboCategory = ""
TxtTRNo = ""
CoboEmployee = ""
StartDate.SetFocus

End Sub


Private Sub UserForm_Activate()
Call UnprotectAllSheets
End Sub


Private Sub CommandButton1_Click()
' Ok Button

Range("A4:J5000").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range _
("AP1:AY3"), CopyToRange:=Range("AP4:AY5000"), Unique:=False

Sheets("DailyIssue").Select
Range("AP3:AY3") = ""

End Sub


Private Sub CommandButton4_Click()
' Export Button to prepare report

Sheets("DailyIssue").Select
Range("AP5:AY500").Select
Selection.Copy

Sheets("ReportIssue").Select
Range("A5").Select
ActiveSheet.Paste
Range("F1").Select

Sheets("DailyIssue").Select
Range("AP3:AY3") = ""
Range("A4").Select


'clear all searched data to control size of file
Sheets("DailyIssue").Select
Range("AP5:AY5000") = ""


Sheets("ReportIssue").Select

' del all blank rows after data, to control size of file
Call DelIssueBlankRowsBottom

Call ProtectAllSheets
Unload Me

End Sub



Private Sub CommandButton5_Click()
' Back to Issue Form (Data Entry)Button
Unload Me
DailyIssueDataEntry.Show
End Sub



Private Sub CommandButton2_Click()
' Close Form Button

Unload Me
'clear all searched data to control size of file
Sheets("DailyIssue").Select
Range("AP5:AY5000") = ""

Call ProtectAllSheets

End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)

' Disable the "X" on the userform so that the user can't
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox Prompt:=" Sorry but I can't let you do that. "
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Sum and Counta function in Listbox for UserForm

You can link the cell to the UserForm control by setting the ControlSource
property of the control, either in the object properties within VB Editor or
in code within the UserForm (typically the initialize event).

TextBox1.ControlSource = "Sheet1!A1"

Using a text box does means any changes to the textbox value will result in
changes to the cell. This is I think your problem?

By setting the value property directly with a range reference avoids this
and you can control the writing to and from the sheet. Any changes in the
cell will not be automatically updated in the UserForm control, so you need
to arrange to refresh it.

TextBox1.Value = Sheets("Sheet1").Range("A1")

Prevent changes to the control affecting the sheet by disabling the control.

TextBox1.Enabled = False

Alternatively use a label to display the cell value

Label1.Caption = "Total: " & Sheets("Sheet1").Range("A1")

You will need to arrange to refresh this whenever changes are made.

--

Regards,
Nigel




"Shazi" wrote in message
...
Hi,

I design the Userform for the Query, its working very nice, in this
form I can get the filtered data in the listbox.

I need two extra textbox in my userform to display the total number of
Records and the Sum of the total amount. how to make this I dont know.
I put the formula in the worksheet, and connect to the Userform with
textbox, upon loading the userform its deleting the formula in the
worksheet.

Pls help me out how to make this procedure.

Waiting for reply.

With Best Regard.

Pls fine below my procedure in the UserForm.


Syed Shahzad Zafar
Madinah

Option Explicit

Private Sub UserForm_Initialize()

HideTitleBar Me ' this command is link to Macro: Hide_TitleBar of
userform

Sheets("DailyIssue").Select
Range("A1").Activate

StartDate = ""
EndDate = ""
MaterialName = ""
CoboCategory = ""
TxtTRNo = ""
CoboEmployee = ""
StartDate.SetFocus

End Sub


Private Sub UserForm_Activate()
Call UnprotectAllSheets
End Sub


Private Sub CommandButton1_Click()
' Ok Button

Range("A4:J5000").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range _
("AP1:AY3"), CopyToRange:=Range("AP4:AY5000"), Unique:=False

Sheets("DailyIssue").Select
Range("AP3:AY3") = ""

End Sub


Private Sub CommandButton4_Click()
' Export Button to prepare report

Sheets("DailyIssue").Select
Range("AP5:AY500").Select
Selection.Copy

Sheets("ReportIssue").Select
Range("A5").Select
ActiveSheet.Paste
Range("F1").Select

Sheets("DailyIssue").Select
Range("AP3:AY3") = ""
Range("A4").Select


'clear all searched data to control size of file
Sheets("DailyIssue").Select
Range("AP5:AY5000") = ""


Sheets("ReportIssue").Select

' del all blank rows after data, to control size of file
Call DelIssueBlankRowsBottom

Call ProtectAllSheets
Unload Me

End Sub



Private Sub CommandButton5_Click()
' Back to Issue Form (Data Entry)Button
Unload Me
DailyIssueDataEntry.Show
End Sub



Private Sub CommandButton2_Click()
' Close Form Button

Unload Me
'clear all searched data to control size of file
Sheets("DailyIssue").Select
Range("AP5:AY5000") = ""

Call ProtectAllSheets

End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)

' Disable the "X" on the userform so that the user can't
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox Prompt:=" Sorry but I can't let you do that. "
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Sum and Counta function in Listbox for UserForm

On Jul 10, 8:22*am, "Nigel" wrote:
You can link the cell to the UserForm control by setting the *ControlSource
property of the control, either in the object properties within VB Editor or
in code within the UserForm (typically the initialize event).

* *TextBox1.ControlSource = "Sheet1!A1"

Using a text box does means any changes to the textbox value will result in
changes to the cell. This is I think your problem?

By setting the value property directly with a range reference avoids this
and you can control the writing to and from the sheet. Any changes in the
cell will not be automatically updated in the UserForm control, so you need
to arrange to refresh it.

*TextBox1.Value = Sheets("Sheet1").Range("A1")

Prevent changes to the control affecting the sheet by disabling the control.

TextBox1.Enabled = False

Alternatively use a label to display the cell value

Label1.Caption = "Total: " & *Sheets("Sheet1").Range("A1")

You will need to arrange to refresh this whenever changes are made.

--

Regards,
Nigel


"Shazi" wrote in message

...



Hi,


I design the Userform for the Query, its working very nice, in this
form I can get the filtered data in the listbox.


I need two extra textbox in my userform to display the total number of
Records and the Sum of the total amount. how to make this I dont know.
I put the formula in the worksheet, and connect to the Userform with
textbox, upon loading the userform its deleting the formula in the
worksheet.


Pls help me out how to make this procedure.


Waiting for reply.


With Best Regard.


Pls fine below my procedure in the UserForm.


Syed Shahzad Zafar
Madinah


Option Explicit


Private Sub UserForm_Initialize()


HideTitleBar Me * * ' this command is link to Macro: Hide_TitleBar of
userform


* * * *Sheets("DailyIssue").Select
* * * *Range("A1").Activate


* * * *StartDate = ""
* * * *EndDate = ""
* * * *MaterialName = ""
* * * *CoboCategory = ""
* * * *TxtTRNo = ""
* * * *CoboEmployee = ""
* * * *StartDate.SetFocus


End Sub


Private Sub UserForm_Activate()
* *Call UnprotectAllSheets
End Sub


Private Sub CommandButton1_Click()
' * Ok Button


Range("A4:J5000").AdvancedFilter Action:=xlFilterCopy,
CriteriaRange:=Range _
* * * *("AP1:AY3"), CopyToRange:=Range("AP4:AY5000"), Unique:=False


* *Sheets("DailyIssue").Select
* *Range("AP3:AY3") = ""


End Sub


Private Sub CommandButton4_Click()
' * Export Button to prepare report


* *Sheets("DailyIssue").Select
* *Range("AP5:AY500").Select
* *Selection.Copy


* *Sheets("ReportIssue").Select
* *Range("A5").Select
* *ActiveSheet.Paste
* *Range("F1").Select


* *Sheets("DailyIssue").Select
* *Range("AP3:AY3") = ""
* *Range("A4").Select


* *'clear all searched data to control size of file
* *Sheets("DailyIssue").Select
* *Range("AP5:AY5000") = ""


* *Sheets("ReportIssue").Select


* *' del all blank rows after data, to control size of file
* *Call DelIssueBlankRowsBottom


* *Call ProtectAllSheets
* *Unload Me


End Sub


Private Sub CommandButton5_Click()
' * Back to Issue Form (Data Entry)Button
* *Unload Me
* *DailyIssueDataEntry.Show
End Sub


Private Sub CommandButton2_Click()
' * Close Form Button


* *Unload Me
* *'clear all searched data to control size of file
* *Sheets("DailyIssue").Select
* *Range("AP5:AY5000") = ""


* *Call ProtectAllSheets


End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)


' Disable the "X" on the userform so that the user can't
If CloseMode = vbFormControlMenu Then
* *Cancel = True
* *MsgBox Prompt:=" Sorry but I can't let you do that. "
End If
End Sub- Hide quoted text -


- Show quoted text -


Hi, Dear Mr. Nigel

Thank you for spending time for me, the solution you sent to me I
applied in my program, and its working very good. this is the
solution I was expected., you understand what I want exactly and what
I was doing exactly.

now my problem is solved. thank you once again....

with best regards.

Shahzad Zafar
Madinah
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
COUNTA Function sgl Excel Worksheet Functions 4 December 13th 08 04:01 PM
Counta function Help Excel Worksheet Functions 3 July 2nd 08 07:01 PM
Using the COUNTA function JL1976 Excel Discussion (Misc queries) 1 October 26th 07 01:28 AM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
COUNTA Function not working =COUNTA(C3:C69,"NH") MikeinNH Excel Worksheet Functions 2 November 8th 04 01:19 AM


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