+ Reply to Thread
Results 1 to 5 of 5

How to add two ranges using Macro in Excel 2007?

  1. #1
    Forum Contributor
    Join Date
    02-02-2008
    Location
    EU
    MS-Off Ver
    MS Excel 2007 Professional version
    Posts
    214

    How to add two ranges using Macro in Excel 2007?

    I am giving you just an example what to achieve:

    Sub Uppercase()
    ' Loop to cycle through each cell in the specified range.
    For Each x In Range("K2:K1000")
    For Each x In Range("M2:M1000")
    ' Change the text in the range to uppercase letters.
    x.Value = UCase(x.Value)
    Next
    End Sub
    It is working one range but how to add also another range Range("M2:M1000") like above example:


    Sub Uppercase()
    ' Loop to cycle through each cell in the specified range.
    For Each x In Range("A1:A5")
    ' Change the text in the range to uppercase letters.
    x.Value = UCase(x.value)
    Next
    End Sub
    Need help.

  2. #2
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,027

    Re: How to add two ranges using Macro in Excel 2007?

    You can use Union funtion to merge multiple range.

    Set r = Union(Range("K2:K10000"), Range("M2:M10000"))

  3. #3
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: How to add two ranges using Macro in Excel 2007?

    Or;

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: How to add two ranges using Macro in Excel 2007?

    Faster to read your ranges into an array, change there and bulk paste it back.
    Please Login or Register  to view this content.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  5. #5
    Forum Contributor
    Join Date
    02-02-2008
    Location
    EU
    MS-Off Ver
    MS Excel 2007 Professional version
    Posts
    214

    Re: How to add two ranges using Macro in Excel 2007?

    Thank you. It is working.

+ 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. How do I Update Specific Access 2007 Table Fields Using Excel 2007 Macro?
    By anton20 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-05-2014, 02:49 PM
  2. Excel 2007 : IF functions with Date ranges
    By ortiz718 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-24-2014, 03:20 PM
  3. Excel 2007 : Using SUMIFS and date ranges...
    By anthropaulogy in forum Excel General
    Replies: 3
    Last Post: 09-06-2012, 07:05 AM
  4. Same name ranges in Excel 2007
    By TheRobsterUK in forum Excel General
    Replies: 1
    Last Post: 03-10-2011, 10:31 AM
  5. Using named data ranges in charts (Excel 2007)
    By Sam_Gregson in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-09-2009, 01:50 PM
  6. excel 2007 macro - connect to access 2007 database
    By .paul. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2009, 01:41 PM
  7. Pasting From Multiple Copied Ranges in Excel 2007
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 10-31-2007, 04:12 AM
  8. [SOLVED] Excel 2007 Beta-Named Ranges
    By reno in forum Excel General
    Replies: 4
    Last Post: 06-26-2006, 04:45 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