+ Reply to Thread
Results 1 to 11 of 11

ADD ITEM Button Vba Code

  1. #1
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Lightbulb ADD ITEM Button Vba Code

    Hi,

    I would like to have a button named "ADD ITEM". The button will be copy the value to another cell which named "Item Code" column. This column one of other column which represent details item purchase in invoice. The original value come from another search "code for item'. My question - how to copy to "item code" column with automatically when new value added there will be at new row in the same column.

    Thanks.

  2. #2
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    Hi

    Attached my invoice project for your reference. You can see button ADD ITEM is function to copy value M15 to B15. But I dont know to add more item that suppose to go to next row same column.

    Thanks.
    Attached Files Attached Files

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ADD ITEM Button Vba Code

    I have attached an app from the depths of my archives of yesteryear.
    The process is similar to that which you appear to want.
    Note there are data validation dropdowns in 'H6' and range 'D16:D25'
    The print/save button will transfer to a USB drive and save/create a PDF document.
    Hopefully the technique may prove of some assistance.
    The data sheets are of a 'structured table' format which gives a more structured way of handling info.
    Attached Files Attached Files
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  4. #4
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    Hi.
    Thanks for the reply , i think there is some misunderstanding here, what i am looking here is a vb macro code for ADD ITEM. As sample you have provided,item name is input by drop down list which I have problem using this feature due to drop down is not a searchable tools. I am using pivot filter for search item. Without any VB code, this pivot filter is powerful search that easily can search my item database which almost 100 item. That search will response to the Code box. All the item which tags with code number can add/input into Code no column and automatically show item description, price and others. The ADD ITEM button i have created as you can try, will copy the value from the Code box to Code num column. My Code is simple code to copy from Code box to Code num.

    Set myrange1 = Range("B21")
    Set myrange2 = Range("M15")


    myrange1.Value = myrange2.Value


    End Sub

    But to add more item is not working caused the code is only will overwrite the 1st row not to go second row.

    hope my explanation will help you understand

    Thanks anyway
    Attached Files Attached Files

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ADD ITEM Button Vba Code

    small macro on orange button.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    Thanks a lot..its really help...really appreciate it.

  7. #7
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    Hi..i have tried to lock the formula, but got error 1004,

    debug line

    For f = 41 To 21 Step -1
    If Sheet1.Cells(f, 2) = vbNullString Then
    rrow = f
    End If
    Next f
    Sheet1.Cells(rrow, 2) = [M15] ->error

    Range("C21:C41").WrapText = True
    Range("C21:C41").EntireRow.AutoFit

    Range("C12:C13").WrapText = True
    Range("C12:C13").EntireRow.AutoFit

    How can protect my formula and make this code working?
    TQ

  8. #8
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    I think can ignore this...for now i just untick locked protection cell. and Its working, sorry for the post.i

  9. #9
    Registered User
    Join Date
    08-24-2015
    Location
    Kuala Lumpur
    MS-Off Ver
    MS office 2007
    Posts
    9

    Re: ADD ITEM Button Vba Code

    Hi ,
    Now i really stuck with my protected worksheet.I have made refresh button to refresh my pivot data. Its works, but its clash with Autofit code which enable in ADD ITEM to autofit all list row. I have tried to put some Allowcolumn and row code but it doesnt work.

    With ActiveSheet
    .Unprotect Password:="password"
    .PivotTables(1).RefreshTable

    .Protect Password:="password", _
    AllowUsingPivotTables:=True
    AllowFormatrow = True
    AllowFormatcolumn = True


    End With

    End Sub

    Attached my project excel for your reference. Protect pass:password.

  10. #10
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ADD ITEM Button Vba Code

    Sorry, I do not use formula in form templates if I am using VBA/macros.
    I would do all the work with code, that way there is less need to protect the template.
    Your problem is the fact you are using the template as the input as well (always fraught with accidental corruption).
    I have attached a simple example of form template population (note no formula in template all in the code) (you could make the sheet(template) hidden)
    Please update your past posts by putting your code snippets between code tags. 'hash' (#) in the reply box upper menu.
    Please Login or Register  to view this content.

  11. #11
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: ADD ITEM Button Vba Code

    thanks for the feedback and added rep point.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 06-18-2021, 04:29 AM
  2. [SOLVED] Vba to match item description and copy/paste item code to other sheet
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2017, 11:29 AM
  3. VBA code to create pivot for single pivot item, if required item is not available cre
    By Ishwarind in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2016, 11:06 AM
  4. How to remove an item from a list box with a button
    By SasukeOfTheLeaf in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-19-2014, 06:23 PM
  5. Searching Item Code And Item Number
    By Shi in forum Excel General
    Replies: 3
    Last Post: 11-23-2013, 03:33 AM
  6. scrolling through listbox item's with button's
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-04-2009, 04:45 AM

Tags for this Thread

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