Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6981295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:08:17+00:00 2026-05-27T18:08:17+00:00

My Excel sheet has multiple used ranges. I want to copy each range value

  • 0

My Excel sheet has multiple used ranges. I want to copy each range value and concatenate them. What I did is

Set tempRange = Union(SrcWkb.Worksheets("mysheet").Range("F1:H1"), SrcWkb.Worksheets("mysheet").Range("I1:J1"), SrcWkb.Worksheets("NWP").Range("K1:L1"))

For Each eachRange In tempRange
  tempString = tempString & eachRange & "/"
  MsgBox tempString
Next eachRange

I want to copy the value in merged cells F1:H1 and concatenate a “/” and value from I1:J1 (also merged) and K1 to L1. However, Excel throws “subscript out of range” error. How could I achieve this?

screenshot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:08:18+00:00Added an answer on May 27, 2026 at 6:08 pm

    It is not quite clear from your original post what output you need. Here is one option which may help you get started:

    Sub ConcatRanges()
        Dim rangeOne As Range, rangeTwo As Range, rangeAll As Range, cl As Range, str As String
    
        Set rangeOne = Worksheets("mysheet").Range("I27:K27")
        Set rangeTwo = Worksheets("mysheet").Range("L27:N27")
        Set rangeAll = Union(rangeOne, rangeTwo)
    
        For Each cl In rangeAll
            str = str & cl & " / "
        Next cl
    
        Debug.Print str //Output: 1 / 2 / 3 / 4 / 5 / 6 /
    End Sub
    

    Updated Post

    Dealing with merged ranges can be tricky. For example, the merged range F1:H1 has value 36M. To access the value you have to refer to the first cell in the merged range. Example:

    Sub MergedRangeDemo()
        Dim rng As Range, cl As Range
        Set rng = ActiveSheet.Range("F1:H1")
    
        For Each cl In rng
            Debug.Print cl.Value, cl.Address
        Next cl
    
        //Output: 36M    $F$1  <-- Only first cell contains the value
        //               $G$1
        //               $H$1
    End Sub
    

    Given this you can concatenate the values by using the rowindex (1) of the range:

    Sub ConcatRangesUpdated()
        Dim rangeOne As Range, rangeTwo As Range, rangeThree As Range, str As String
    
        Set rangeOne = ActiveSheet.Range("F1:H1")
        Set rangeTwo = ActiveSheet.Range("I1:J1")
        Set rangeThree = ActiveSheet.Range("K1:L1")
    
        str = rangeOne(1) & " / " & rangeTwo(1) & " / " & rangeThree(1)
    
        Debug.Print str 'Output: 36M / 40M / 36M
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to select the Excel sheet used range via OLEDB Command
I am reading excel sheet using openrowset function? My Excel sheet has numeric value
In a cell in Excel sheet I have a Date value like: 01/01/2010 14:30:00
I have an EXCEL sheet.it has various form-fields that are named as smrBgm133GallonsGross/ smrBgm167GallonsGross
I have an excel sheet which has about 150,000 records, operations like find replace,
Hi i have an excel sheet with headers,i want to populate those headers into
I have a few hundred Excel files, where each file has some data on
I have an excel sheet which has some huge data. Data is organized as
Possible Duplicate: Copy column from one Excel sheet to another Excel sheet I have
my app in c# has a prob in writing to excel sheet. My app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.