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 5989987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:10:46+00:00 2026-05-22T23:10:46+00:00

I have the following problem. I want to call a soubroutine for changing the

  • 0

I have the following problem. I want to call a soubroutine for changing the background color for a cell range. The cell range is calculated with cells(1,1) and then the address is calculated to receive A1.

Before the subroutine is called I get the addresses for my cells like this:

Range1 = cells(4, 4).Address(RowAbsolute:=False, ColumnAbsolute:=False)
Range2 = cells(4, CellAmount - 1).Address(RowAbsolute:=False, ColumnAbsolute:=False)

I thought I need this because the subroutine is declared like this:

Sub SetBGLightGrey(cells As String)

    range(cells).Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 15921906
        .TintAndShade = 0
       .PatternTintAndShade = 0
    End With

End Sub

Range 1 and Range 2 are strings and I concat it to a range declaration:

RangeArea = """" & Range1 & ":" & Range2 & """"

When I call my subroutine like this:

Call SetBGLightGrey(RangeArea)

I get the following error-message:

“Run-time error ‘1004’: Method ‘Range’ of object ‘_Global’ failed. I don’t understand it because if I call the subroutine with the correct cell values:

Call SetBGLightGrey("D4:K4")

it works. It is string and of the same value. This simply cannot be can it?

  • 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-22T23:10:46+00:00Added an answer on May 22, 2026 at 11:10 pm

    You do not need quotes around RangeArea.

    RangeArea = Range1 & ":" & Range2
    

    But then, why would you want to pass ranges around as strings and then convert them back to ranges? Pass the range objects all the time.

    Sub SetBGLightGrey(byval cells as range)
      With cells.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 15921906
        .TintAndShade = 0
        .PatternTintAndShade = 0
      End With
    End Sub 
    
    SetBGLightGrey range(cells(4, 4), cells(4, CellAmount - 1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using GWT/JAVA for development. I have following problem: I want to remove
I have the following problem that I want to solve in awk. I have
I have the following problem: Within a stylesheet document I want to create an
I have the following problem. I want to check that the item clicked on
Hi I have the following problem, I want to laod a website with php.
What kind of strategy do I have for the following problem. I want to
I have the following code I want to run, but the problem is $this->type
I have the following code: The actual problem is the non-quoted code. I want
I have following problem: I want to check (C#) if a thread has finished
Hello i have the following problem. I have a search page lets call it

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.