New to Excel Macros and need some hlep


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: New to Excel Macros and need some hlep

  1. #1
    Join Date
    Mar 2008
    Posts
    1

    New to Excel Macros and need some hlep

    Hi guys,

    I need to develop an Excel Macro that will insert the correct country code for a list of phone numbers.

    I'm thinking I'll have a prompt, something like "Enter Country Code:" where the user would enter the code and then it would be added to all phone numbers in the list. Eg. For a list of Turkish phone numbers I'd enter 90, and the list of phone numbers would have +90 added to them.

    The trouble is I have no Idea where to start as I haven't had experience with Excel Macros before.

    Note, this isn't just a script request because I actually like to learn how to do this sort of thing so if someone could guide me through the development of this macro that would be great.

    Thanks in advance.

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,261
    For a simple method, your macro could use the Selection object to determin if anything has been selected for updating. If there is anything there then use the builtin InputBox function to pop open a messagebox that asks for the country code. Once you have the country code you would then loop through the selection objects cells and update those items with the country code.
    If you have not worked with Excel Macros before, I suggest that you find something very simple that you want to do, then turn on the macro recorder, do the steps you want, then stop the macro recorder. Save the new macro and then look at what Excel created in the VBA Editor. Once you do a few of these, and see how Excel does the work, you will then feel more comfortable creating your own macros.
    Maybe start super simple and just add a country code to the currently active cell. Don't even ask for which code just use +90 to start. Once you get that to work then you can add in the InputBox() function to ask for the code. Then once you get that to work then you can add the looping code to loop through the selection object. Basically get one thing to work at a time, until you can do it all.
    Good Luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center