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

  • Home
  • SEARCH
  • 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 7649565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:59:55+00:00 2026-05-31T10:59:55+00:00

I wonder if anyone knows how to select a rectangle range of values? This

  • 0

I wonder if anyone knows how to select a rectangle range of values? This range will not be fixed. For this particular example, it will select B5 – G7 in a rectangle form and then it will set a condition format to add in some colors.

I have attempted the codebut it is giving me an error at this portion

ActiveSheet.Cells(colorrow & "2", _
ActiveSheet.Cells(colorrow & "2").End(xlDown).End(xlToRight)).Select

wonder if anyone know why? will be thankful!

enter image description here

I have attempted writing out some coding.

My code is as follows:

Sub Macro2()

 Dim thevaluestocopy As Variant, colorCell as Range, colorrow as Long, thefirstcolorrow as Long

 colorrow = 1

Do

Set colorCell = Sheets("Sheet1").Cells(colorrow, 1)
'check for test1-test6 if its around do nothing, else goes to the next row and next column
If colorCell = "test1" Or colorCell = "test2" Or colorCell = "test3" _
Or colorCell = "test4" Or colorCell = "test5" Or colorCell = "test6" _ Then 
'Do nothing
Else
thefirstcolorrow = Sheets("Sheet1").Cells(colorrow, 2)
'This statement gives me the error.. not sure why it cant work 
ActiveSheet.Cells(colorrow & "2", _
ActiveSheet.Cells(colorrow & "2").End(xlDown).End(xlToRight)).Select
Exit Do
End If
colorrow = colorrow + 1
Loop


'add colors into cell
ActiveCell.Select
Selection.FormatConditions.AddColorScale ColorScaleType:=3
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).ColorScaleCriteria(1).Type = _
    xlConditionValueLowestValue
With Selection.FormatConditions(1).ColorScaleCriteria(1).FormatColor
    .Color = 8109667
End With
Selection.FormatConditions(1).ColorScaleCriteria(2).Type = _
    xlConditionValuePercentile
Selection.FormatConditions(1).ColorScaleCriteria(2).Value = 50
With Selection.FormatConditions(1).ColorScaleCriteria(2).FormatColor
    .Color = 8711167
End With
Selection.FormatConditions(1).ColorScaleCriteria(3).Type = _
    xlConditionValueHighestValue
With Selection.FormatConditions(1).ColorScaleCriteria(3).FormatColor
    .Color = 7039480
End With

End Sub
  • 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-31T10:59:57+00:00Added an answer on May 31, 2026 at 10:59 am

    I have found out a way. and like to share it with the rest..

    Sub Macro2()
    
    Dim colorCell As Range, colorrow As Long, thefirstcolorrow As Long, colorrow1 As Long, colorCell1 As Range, nvalue As Long
    Dim thelastcolorRow As Long, n As Long, LastColtocolor As Long
    
    colorrow = 1
    
    LastColtocolor = Sheets("Sheet1").Cells("1" & Columns.Count).End(xlToLeft).Column
    
    Do
    
    Set colorCell = Sheets("Sheet1").Cells(colorrow, 1)
    
    'Check if cell holds any value of test1 - test6, etc...
    If colorCell = "test1" Or colorCell = "test2" Or colorCell = "test3" _
    Or colorCell = "test4" Or colorCell = "test5" Or colorCell = "test6" _ Then 
    'Do nothing
     Else
     thefirstcolorrow = colorrow
    
    Exit Do
    End If
    
    colorrow = colorrow + 1
    Loop
    
    colorrow1 = 1
    
    Do
    'Look for last row that has values
    Set colorCell1 = Sheets("Sheet1").Cells(colorrow1, 1)
    If colorCell1 = "" Then
    thelastcolorRow = colorrow1
    
    Exit Do
    End If
    colorrow1 = colorrow1 + 1
    Loop
    
    For nvalue = 1 To colorrow1 - 1 - colorrow
    
    Sheets("Sheet1").Range(Cells(thefirstcolorrow, 2), Cells(thefirstcolorrow + nvalue, LastColtocolor)).Select
    
    Next nvalue
    
    End sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if anyone knows how to get this Lion-style toolbar items like we
I just wonder if anyone knows or made a wrapper around Active Directory to
I wonder if anyone knows how could I rename multiple files, all of them
Anyone knows an equivalent class of Java's SimpleDateFormat in C#? I wonder if i
I need help with the following wonder if anyone knows what i can do
I wonder if anyone knows the (optimal?) algorithm for longest recurring non-overlapping sub string.
I wonder if anyone knows why the following two pieces of code behave very
I wonder if anyone knows of a good framework or advice of how to
I wonder if anyone knows about WAFL (Write Anywhere File Layout), or a link
I wonder if anyone knows how to get a specified amount of elements for

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.