+ Reply to Thread
Results 1 to 6 of 6

Calling macros for items in Combobox

  1. #1
    Registered User
    Join Date
    01-12-2014
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    77

    Calling macros for items in Combobox

    Hi,

    I am trying to run macros for each item in combobox. These macros will insert text in a cell. The problem is that when i make a selection from combobox, save the file and reopen the file, it again runs the macro based on the value in combobox. I am getting the results twice in a cell.

    I've written the following code.

    Please Login or Register  to view this content.
    Can you please tell how to avoid this problem..

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Calling macros for items in Combobox

    Hi, laxminarayana,

    check the contents of the targeted cell by using Len or using IsEmpty and only then run macro?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Calling macros for items in Combobox

    How/when are you populating the combobox?

    Also, if all the macros do is enter text based on what's selected couldn't it be done with one macro?

    That macro could look at what's selected to determine what text to put in the cell.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    01-12-2014
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    77

    Re: Calling macros for items in Combobox

    Hi,

    The text inserted by macros is combination of text and dates. I have attached my excel file can you please have a look.

    Thank You
    Attached Files Attached Files

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Calling macros for items in Combobox

    Hi, laxminarayana,

    if you donīt want the data to double up you should not add the text to the data available in that cell but overwrite it.

    Instead of
    Please Login or Register  to view this content.
    you could try
    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    01-12-2014
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    77

    Re: Calling macros for items in Combobox

    Thank you.

+ 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. Populating Userform ComboBox Using Items from Content Control Combobox
    By anarxo in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2014, 01:00 PM
  2. Populating combobox 2 with items that match criteria from combobox 1
    By kuraitori in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-13-2013, 03:00 AM
  3. Add combobox to a Word doc and populate the combobox with list of about 65 items
    By excelaron in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 06-21-2012, 01:59 PM
  4. How do I refer to the items in a combobox by their number in the list of items?
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2007, 10:03 PM
  5. Problems calling macros in addin from within macros
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2005, 05:05 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