Best Approach To Formatting A Merged Range of Cells

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
My goal:
Range AP2:AX2 cells filled with green, grouped (merged) range of cells with a white border. Of the full range , AP2:AW2 hold a string value. AX2 is empty as a cell on its own.

Data_Prep.xlsm
APAQARASATAUAVAWAX
2RMR Ï12:32:12
GUI_1


This is the image.

Here is the code I am trying, which works except for excluding AX2 independent of the merged AP2:AW2.

Any suggestions what I can do to improve the code to achieve the result I desire?

Code:
        With .Range("AP2:AX2")

              .Merge
              With .Borders
                   .LineStyle = xlContinuous
                   .Weight = xlThin
                   .Color = vbWhite
              End With
              .Interior.Color = RGB(0, 176, 80)

              .Range("AP2:AW2").Merge
              .Range("AP2").Value = st_cd
        End With
        .Range("AX2") = Format(Now, "h:mm:ss")
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Is this what you want ?
VBA Code:
    .Range("AP2").Value = st_cd
    With .Range("AP2:AW2")
        .Merge
    End With
    .Range("AX2") = Format(Now, "h:mm:ss")
    With .Range("AP2:AW2,AX2")
        
        With .Borders
            .LineStyle = xlContinuous
            .Weight = xlThin
            .Color = vbWhite
        End With
        .HorizontalAlignment = xlCenter
        .Interior.Color = RGB(0, 176, 80)
        .Font.Color = vbWhite
    End With
 
Upvote 0
It sure is Yongle!!
I appreciate you're having identifying and correcting my errors. It looks like I just simply had my process out of order, but I wouldn't have known without your help.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top