+ Reply to Thread
Results 1 to 34 of 34

Adding a count function to a formula.

  1. #1
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Adding a count function to a formula.

    Hi

    I'm using this code:
    Please Login or Register  to view this content.
    And the .offset(1,4) - Colum E would have values that depend on the cell above.
    It starts with Cell E3 and the value of Cell E3 would be D0001 and the Cell E4 would depend on the cell E3 and the value of cell E4 would be D0002 and so on... I tryed doing it with some formulas and I couldn't get it to work right. Would some one help me with this please?
    Last edited by stojko89; 11-17-2011 at 06:08 AM.

  2. #2
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Please Login or Register  to view this content.
    Try this
    Please take time to read the forum rules

  3. #3
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Ok, so here is what I did:

    Please Login or Register  to view this content.
    It says Compile Error:

    For without Next

  4. #4
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Yes., you are missing this line right before "Unload me"

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Ok so now it works. But it doesn't enter the next D000* number in Colum E

  6. #6
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Try uploading your workbook, and i'll have a look.

    It works at my end!

  7. #7
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Ok here goes

    I've added a copy of the workbook.

    The UserForm is when you click the Novo Narocilo button and then in this userform u have to click Nov Dobavitelj. And when You click Dodaj your code should work for the sheet UserFormInfo
    You'll see

    Here is the code I'm using:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Maby its not working becose the value of the cell above is D0010 and doesn't have three zeros' like this D0002 ?

    Couse I need the code to from
    D0001
    D0002
    D0003
    D0004
    D0005
    D0006
    D0007
    D0008
    D0009
    D0010
    D0011
    So the number of signs stay 6

  9. #9
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Ok, found the solution, simple as it is

    change this line
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    I saw that it was changing the line above when I was adding a nother company but I was runining around this part of the code:

    Please Login or Register  to view this content.
    But I had no luck.

    But now the code works perfect!

    Thank you very much again! :D

  11. #11
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Your welcome!

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    or
    Please Login or Register  to view this content.
    Last edited by snb; 11-17-2011 at 06:37 AM.



  13. #13
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    snb your code works in one way but not quite correct:

    It changed all of the numbers from E3 to E58 even though the A colum is filled to cell A13
    And the numbers go like this:
    D0549
    D0549
    D0551
    D0563
    D0563
    D0564
    D0568
    D0570
    D0571
    D0571
    D0575
    D0576
    D0576
    D0578
    istead of:
    D0001
    D0002
    D0003
    D0004
    D0005

    But thank you for giving it a swing and a different code
    Steffen got the code working correctly for me.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    In that case

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Now it says:

    Run-TIme Error 438

    Object doesn't support this property or method

    And when I hit debug it colors this line:

    Please Login or Register  to view this content.

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    Please Login or Register  to view this content.

  17. #17
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Almost there

    Now it does this:

    When I hit add and the text is copyed in Cells A5,B5,C5,D5 - E5 stays empty
    When I hit add for another company it copys the text under those above and looks like this:
    text copyed to A6,B6,C6,D6 - E5 gets the right number but E6 stays empty

    So it doesn't add the number in the row it sopose to but later if I add 2 companys and when I add the second company it enters the correct velue for the first company.

  18. #18
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Hi,

    Actually this would be enough
    Please Login or Register  to view this content.

  19. #19
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Steffen it says:
    Argument not optional and then it highlights:

    Format(Right

    Just the word Right.

    And I put in the code like this:

    Please Login or Register  to view this content.

  20. #20
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    Sorry, just left out a bit

    Please Login or Register  to view this content.
    It should be placed outside the with statement you allready have
    Last edited by Steffen Thomsen; 11-17-2011 at 08:57 AM.

  21. #21
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    Please Login or Register  to view this content.
    If you need a next number you do not need to renumber the whole column again.
    Last edited by snb; 11-17-2011 at 09:00 AM.

  22. #22
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    So I don't open a new thread I'll ask here: I'm tryn to copy multiple cells in a textbox in a UserForm if its even possible and I'm doin it like this but I keep geting an error for object not defined:

    Please Login or Register  to view this content.
    I'll try the 2 codes and I'll let you know how it goes

  23. #23
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    Basically:

    Please Login or Register  to view this content.

  24. #24
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    snb no luck.

    Now it's copying down the name in colum A like this:

    A3 = Pahor - and then it makes
    A4 = Pahor
    A5 = Pahor.....and so on
    Colum E stays empty.

    Steffen your code doesn't work like this:
    Please Login or Register  to view this content.
    Says Argument not optional and colors the same part of the code (The word Right)

  25. #25
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    snb For the code:
    Please Login or Register  to view this content.
    It says Type Mismatch.
    The code should take every text between Colum A and F and number of rows = untill the text stops.

  26. #26
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    Please Login or Register  to view this content.

  27. #27
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    You can't put a multidimensional range into a textbox, unless:

    Please Login or Register  to view this content.
    But I don't think you want so much text in 1 textbox.

  28. #28
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    snb the code showed me an error again and it highlighted this part:
    Please Login or Register  to view this content.
    But you don't have to work on this code anymore, I'll use the one that works.
    Altough it was fun

  29. #29
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Re: Adding a count function to a formula.

    And you didn't copy the right code

    Please Login or Register  to view this content.

  30. #30
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    What if I use a ListBox? Can I somehow put the data from A3:K10 in there?
    I don't know what to enter in under the uptions where it says ControlSource:
    becose this doesn't work '00057-2011'!A3:K10
    And it worked for ComboBox.

  31. #31
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    Steffen

    It says Synax error for this row:
    Please Login or Register  to view this content.

  32. #32
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    I hope we can continue tomorrow
    I have to go home now. And I don't have this wb at home so I can't do anything untill tomorrow 6am when I come back to work.
    So thanks for the help and the effort!

  33. #33
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Adding a count function to a formula.

    at last:

    Please Login or Register  to view this content.

  34. #34
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: Adding a count function to a formula.

    snb! It works! You did it
    Now I have to working codes and I don't know wich one to use
    Thanks again.

    I'll open a new thread for the multirow copy in the textbox or combobox or listbox.

    Thank you bouth again, very much

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1