+ Reply to Thread
Results 1 to 22 of 22

Converting all data in the cells of a column to the same type using a macro

  1. #1
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Converting all data in the cells of a column to the same type using a macro

    How can I automatically convert this data to column A in a worksheet with a macro. So that when I paste (CTRL + V) into the cells of column A, this data is automatically converted?

    For example:

    Please Login or Register  to view this content.
    Should automatically convert to:

    Please Login or Register  to view this content.
    That is, it is necessary that (any number)m and (any number)M be on the right.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    When using this macro, the data must be entered in advance and then run the macro manually. But I need the macro to automatically run on the sheet when data is inserted.
    Last edited by moninah; 09-10-2022 at 02:43 PM.

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Converting all data in the cells of a column to the same type using a macro

    @moninah

    Maybe you can start replying on#2 of Mumps1

    Did the offered solution work or if it fails, on what part did it fail.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make an entry into column A and press the ENTER key.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make an entry into column A and press the ENTER key.
    Please Login or Register  to view this content.
    Thank you! But if enter or paste one word or one number, it gives an error: "Runtime '9': Subscript out of range". It is necessary that one character can be entered, but without conversion. If remove values from a column, then the error also occurs: "Runtime '9': subscript out of range". Need to be able to delete values from cells.

    Attachment 795756
    Last edited by moninah; 09-11-2022 at 11:47 AM.

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    I based the macro on the data you posted in your original post assuming that the format for all cells would always be the same. It would be easier to help and test possible solutions if you could attach a copy of your file that contains the type of data that is possible to be entered in column A. See the yellow banner at the top of this page for instructions to attach a file.

  8. #8
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    I based the macro on the data you posted in your original post assuming that the format for all cells would always be the same. It would be easier to help and test possible solutions if you could attach a copy of your file that contains the type of data that is possible to be entered in column A. See the yellow banner at the top of this page for instructions to attach a file.
    Can enter and paste everything, but not convert. Convert only (any number)m and (any number)M. Can delete and edit data in cells. Only this.

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    It would be helpful if you could post samples of data that show the different formats in which data can be entered. It is difficult to suggest a solution without knowing all the possibilities of what the data can look like.

  10. #10
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Converting all data in the cells of a column to the same type using a macro

    @moninah

    It is also a good idea to add the location in your profile.

    Sometimes the result of the reply depends on the location.

  11. #11
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Solved the problem with:
    Please Login or Register  to view this content.
    Mumps1, Thank you very much for the macro.
    Last edited by moninah; 09-12-2022 at 12:45 PM.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    My pleasure.

  13. #13
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Mumps1, How to make macro work with all cells of column A? So that can paste into several cells at a time and the data is converted. I need this in order to be able to convert multiple data at once.

  14. #14
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    Please post the code that is currently working for you.

  15. #15
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    Please post the code that is currently working for you.
    Please Login or Register  to view this content.

  16. #16
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    Try:
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Does not work. Error: "Run-time error '13': Type mismatch". Line: "v = Split(Target, " ")"
    Last edited by moninah; 09-12-2022 at 01:35 PM.

  18. #18
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    Try:
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    So the macro works with all cells of column A.

    But now if enter or paste with capital "M":
    Please Login or Register  to view this content.
    it will be converted to:
    Please Login or Register  to view this content.

  20. #20
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    I forgot to include this line of code at the very top of the macro:
    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    09-02-2022
    Location
    World
    MS-Off Ver
    2019
    Posts
    15

    Re: Converting all data in the cells of a column to the same type using a macro

    Quote Originally Posted by Mumps1 View Post
    I forgot to include this line of code at the very top of the macro:
    Please Login or Register  to view this content.
    This works great! Thanks a lot again!

  22. #22
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,819

    Re: Converting all data in the cells of a column to the same type using a macro

    You are very welcome.

+ 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. [SOLVED] UBound coll error after converting macro. Runtime error 13. Type mismatch.
    By Elijah in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2020, 05:08 AM
  2. Looking to create a macro that will skip blank cells in a column, find data cells
    By crayzwalz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2013, 09:01 AM
  3. [SOLVED] Converting a column of text data by assigning numbers to each type of response
    By westicles in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-27-2013, 10:26 PM
  4. [SOLVED] Converting text-number to a long data type.
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2012, 07:37 PM
  5. converting dates to general type of data
    By Vogelmann in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-24-2012, 08:49 AM
  6. Converting column data to row data macro
    By unknowndevice in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2005, 04:35 PM
  7. create macro to move label type data to column data
    By JonathonWood9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2005, 07:06 PM

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