LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default why Isn't any of the experts helping me?


-- Hope that you could send the excel file so I could learn from It...

Thanks

joromajr


"joromajr" wrote:


-- you could send your file to . Will wait hope that can
continue to monitor my progress. I really need your help and my gratitude as
we continue with this case.


joromajr


"pallaver" wrote:

Hi Joromajr,

I will send you the excel file tonight hopefully using the email
address listed, but here's what I've done cut and pasted so you can
mimick it:

First, in sheet1 A1 to A4 put the following:
A1 Invoice Number
A2 Invoice Date
A3 Invoice Amount
A4 Account Name

In sheet2 A1 to A4 put the following:
A1 Invoice Number
A2 Invoice Date
A3 Invoice Amount
A4 Account Name

Now get into your visual basic editor, and in Module1 copy paste the
following between the dashed lines:

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

Option Explicit

Public TotalNumberInvoices As Integer
Public TempInvoiceNumber As String
Public i As Integer
Public j As Integer
Public EntryLoop As Integer
Public CompanyNames(0 To 10000) As String
Public ArrayNumber As Integer



Sub Accounting()

EntryLoop = 0

i = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
If i 1 Then
Sheets("Sheet2").Rows("2:" & (i)).ClearContents
End If

Sheets("Sheet1").Select

Do Until EntryLoop = 1
userform1.Show
Loop

Sheets("Sheet2").Select
Sheets("Sheet2").Range("A1").Select

End Sub
-------------------

Now create a userform. In the userform you want 4 text boxes (for
inputting each of the 4 variables), an enter in inputted information
command button, and a combobox (for your search function, part two).
You'll have to make the userform yourself, but this is not that
difficult.

I'll let you figure out what name to give each text box and the
combobox, noting that a textbox variable name ends with TB, and the
combobox variable name ends with CB. If you look at the code, you
should be able to figure it out. Double click on the userform and in
the userform code box put in the following:

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

Option Explicit


Private Sub CompanyNamesCB_Change()

j = 2

For i = 2 To (TotalNumberInvoices + 2)

If Sheets("Sheet1").Cells(i, 4).Value = CompanyNamesCB.Value Then
Sheets("Sheet2").Cells(j, 4).Value = Sheets("Sheet1").Cells(i,
3).Value
Sheets("Sheet2").Cells(j, 1).Value = Sheets("Sheet1").Cells(i,
4).Value
Sheets("Sheet2").Cells(j, 2).Value = Sheets("Sheet1").Cells(i,
1).Value
Sheets("Sheet2").Cells(j, 3).Value = Sheets("Sheet1").Cells(i,
2).Value
j = j + 1
End If

Next i

EntryLoop = 1
userform1.Hide

End Sub

Private Sub EnterInvoice_Click()

If InvoiceNumberTB.Value = "" Or DateInvoiceTB.Value = "" Or
AmountInvoiceTB.Value = "" Or AccountNameCB.Value = "" Then Exit Sub

For i = 2 To (TotalNumberInvoices + 2)

If Val(InvoiceNumberTB.Value) = Sheets("Sheet1").Cells(i, 1).Value
Then
MsgBox "Sorry, this Invoice Number is already taken."
InvoiceNumberTB.Value = ""
Exit For
End If

If Val(InvoiceNumberTB.Value) < Sheets("Sheet1").Cells(i, 1).Value
Then
Rows((i) & ":" & (i)).Insert Shift:=xlDown
Sheets("Sheet1").Cells(i, 1).Value = InvoiceNumberTB.Value
Sheets("Sheet1").Cells(i, 2).Value = DateInvoiceTB.Value
Sheets("Sheet1").Cells(i, 3).Value = AmountInvoiceTB.Value
Sheets("Sheet1").Cells(i, 4).Value = AccountNameCB.Value
Exit For
End If

If i = TotalNumberInvoices + 2 Then
Sheets("Sheet1").Cells(i, 1).Value = InvoiceNumberTB.Value
Sheets("Sheet1").Cells(i, 2).Value = DateInvoiceTB.Value
Sheets("Sheet1").Cells(i, 3).Value = AmountInvoiceTB.Value
Sheets("Sheet1").Cells(i, 4).Value = AccountNameCB.Value
Exit For
End If

Next i


InvoiceNumberTB.Value = ""
DateInvoiceTB.Value = ""
AmountInvoiceTB.Value = ""
AccountNameCB.Value = ""

End Sub



Private Sub Frame2_Click()

End Sub

Private Sub UserForm_Activate()

CompanyNamesCB.Clear


TotalNumberInvoices = Sheets("Sheet1").Range("A" &
Rows.Count).End(xlUp).Row - 1

ArrayNumber = 0

For i = 2 To (TotalNumberInvoices + 2)

If i = 2 Then
CompanyNamesCB.AddItem (Sheets("Sheet1").Cells(i, 4).Value)
AccountNameCB.AddItem (Sheets("Sheet1").Cells(i, 4).Value)
CompanyNames(ArrayNumber) = Sheets("Sheet1").Cells(i, 4).Value
ArrayNumber = ArrayNumber + 1
Else

For j = 0 To ArrayNumber
If Sheets("Sheet1").Cells(i, 4).Value = CompanyNames(j) Then
Exit For
If j = ArrayNumber Then
CompanyNamesCB.AddItem (Sheets("Sheet1").Cells(i,
4).Value)
AccountNameCB.AddItem (Sheets("Sheet1").Cells(i, 4).Value)
CompanyNames(ArrayNumber) = Sheets("Sheet1").Cells(i,
4).Value
ArrayNumber = ArrayNumber + 1
End If
Next j
End If

Next i

End Sub

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

And there you go.

The code is by no means dummy proof - i.e. makes sure that dates are
correct dates (i.e. you can't enter July 45th), or that the number
contains no letters or two decimal points, this just makes it a little
more complicated, but if the user carefully enters in the info, it
should work.

Try it out, post back questions or where things are going wrong.

Since, np

 
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
coding and helping to launch vba biker man Excel Discussion (Misc queries) 1 September 18th 07 12:08 PM
Getting rid of helping columns paulgallanter Excel Worksheet Functions 2 April 9th 06 12:16 AM
Need helping with my formula please... Altstatten Excel Worksheet Functions 1 March 14th 06 08:48 PM
tools helping understand calculations Dmitry Kopnichev Excel Discussion (Misc queries) 5 October 4th 05 06:37 AM
tools helping understand calculations Dmitry Kopnichev Excel Worksheet Functions 5 October 4th 05 06:37 AM


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