+ Reply to Thread
Results 1 to 4 of 4

Macro to bulk edit object values

Hybrid View

MarcoNecroX Macro to bulk edit object... 02-09-2017, 10:12 PM
Maudibe Re: Macro to bulk edit object... 02-10-2017, 01:12 AM
MarvinP Re: Macro to bulk edit object... 02-10-2017, 01:56 AM
MarcoNecroX Re: Macro to bulk edit object... 02-10-2017, 04:29 PM
  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    11

    Macro to bulk edit object values

    Hello wonderful community.


    I need help building a macro to edit parameters in my workbook. My book would look something like this:

    1.png

    There are then two variables I would like to present to my macro. An object name, and an number that will be used to multiply the value adjacent to it.
    So if I tell the macro the values of "Apple" and "0.5", my previous table would look like this:

    2.png

    The result numbers would be integers, of course, rounding down.
    The macro would need to go through all cells in the sheet and search for the key (Apple) and then multiply the value of the cell next to it by our number variable (0.5)


    If you can help me, I would greatly appreciate it.
    Kind regards.
    Last edited by MarcoNecroX; 02-10-2017 at 04:29 PM. Reason: solved!

  2. #2
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

    Re: Macro to bulk edit object values

    Macro,

    Place the following code in a standard module and run the Caller routine to send the parameters to the BulkEdit Macro.

    HTH,
    Maud
    Public Sub BulkEdit(Obj As String, multiplier As Double)
    Dim Keyword As Range, NextKeyword As String
        Set Keyword = ActiveSheet.UsedRange.Find(What:=Obj)
        Keyword.Select
        NextKeyword = Keyword.Address
        Keyword.Offset(0, 1) = Keyword.Offset(0, 1) * multiplier
    Do
        Set Keyword = ActiveSheet.UsedRange.FindNext(after:=Keyword)
        If NextKeyword <> Keyword.Address Then
            Keyword.Select
            Keyword.Offset(0, 1) = Keyword.Offset(0, 1) * multiplier
        End If
    Loop While Not Keyword Is Nothing And Keyword.Address <> NextKeyword
    End Sub
    
    Public Sub Caller()
    BulkEdit "Apple", 0.5
    End Sub

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: Macro to bulk edit object values

    Hi Marco,

    Your problem looks like it can be done using Paste Special much easier than using a macro. See:

    https://trumpexcel.com/multiply-in-e...paste-special/

    Learn how to copy a value (like .5) to the clipboard and then select some other cells and paste special over those cells using multiply.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    11-29-2013
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to bulk edit object values

    @Maudibe: thank you so much for your reply. I was able to work on your code to achieve what I needed.

    @MarvinP: if I have a worksheet with different objects, I only want to change the values for certain ones, so that doesn't help me.


    Thanks!!

+ 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] Matching multiple values in bulk?
    By Fred45 in forum Excel General
    Replies: 4
    Last Post: 11-24-2014, 11:19 AM
  2. Replies: 0
    Last Post: 06-19-2014, 02:09 PM
  3. Bulk Edit Hyperlink Text to Display
    By Viv Smith in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2013, 01:59 AM
  4. Edit Macro to select all values in a column one by one and then print
    By Hollis27 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2009, 01:59 PM
  5. Edit Macro to select all values in a column one by one and then print
    By Hollis27 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2009, 01:56 PM
  6. Edit Macro to select all values in a column one by one and then print
    By Hollis27 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-17-2009, 01:52 PM
  7. converting formulas into values using a macro in visual basic edit
    By F.C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-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