+ Reply to Thread
Results 1 to 6 of 6

Macro to delete lines and change cell values

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    69

    Macro to delete lines and change cell values

    Hi,

    I would like a macro that can do the following:
    • If Columns L and M has just the number 0 in the cell, delete the line.
    • Replace the values in Column G so that the text "1 of 1" -> "1", "2 to 2" -> "2", "1 to 3" -> "3", "1 of 10" -> "10". Basically, changing the cell value to the last number.
    • Replace Column R's cells if it has something in the text, for example looking for "General Admission" in "Example Super Ticket General Admission" and change it to "GA" or looking for "VIP Admission" in "Test Camp Special VIP Admission" and change it to "VIP".

    I've attached before and after XLSX files to show what I mean. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to delete lines and change cell values

    Please Login or Register  to view this content.
    This assumes data begins in row 2. If not, change the number in red font to the correct row number
    Last edited by JLGWhiz; 04-11-2019 at 05:18 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Registered User
    Join Date
    03-21-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    69

    Re: Macro to delete lines and change cell values

    Thanks, works like a charm! Now I'm just missing the last part to replace Column R's cell values to the ones I want.

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to delete lines and change cell values

    Quote Originally Posted by prvimoon View Post
    Thanks, works like a charm! Now I'm just missing the last part to replace Column R's cell values to the ones I want.
    You're welcome. You can probably do the cfolumn R changes using the Replace All feature in the Excel Find/Replace dialog box from the Home tab of the ribbon. If you can list all of the target strings you want to replace with their corresponding replacement values, I could incorporate that into the other code.

    Maybe you can modify this code which uses the two examples you listed.

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 04-12-2019 at 10:47 AM.

  5. #5
    Registered User
    Join Date
    03-21-2014
    Location
    USA
    MS-Off Ver
    Office 2016
    Posts
    69

    Re: Macro to delete lines and change cell values

    From my test of the data provided in the thread and on the original worksheet, the modified macro works great on both and does everything I need it to do. Thanks again for all of your help!

  6. #6
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Macro to delete lines and change cell values

    Quote Originally Posted by prvimoon View Post
    From my test of the data provided in the thread and on the original worksheet, the modified macro works great on both and does everything I need it to do. Thanks again for all of your help!
    You're welcome,
    regards, JLG

+ 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] change macro to delete values in rows
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 06-20-2015, 07:26 AM
  2. [SOLVED] Combine values from multiple cells into one cell, then delete duplicate lines
    By Ocean Zhang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2015, 07:01 PM
  3. [SOLVED] Need Macro to Distribute Values within a Cell to Multiple Lines
    By Ocean Zhang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2014, 02:34 AM
  4. [SOLVED] Macro - To change cell fonts whenever their values change
    By mgs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-22-2012, 03:14 AM
  5. [SOLVED] Macro to Delete useless lines, rearrange by dates and skip lines between different days.
    By Tmc2159 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-12-2012, 02:15 PM
  6. [SOLVED] Macro to Delete Rows and Change Cell Values
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-08-2011, 04:41 PM
  7. macro - look for change in cell, delete other cells
    By davidmangano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2011, 02:44 PM

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