Vba to Spilt Named Range

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Dear All,

Is there a way to check Named Range contains more 254 columns then Split Named range as Excel_Fcast1A and rest columns Excel_Fcast1B?

Code:
'Counts no of Columns in Named Range.
[FONT=Calibri]Range("Forecast").Columns.Count[/FONT]

Not sure how to split Named Range.

Biz
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi

may be..

Code:
Sub kTest()
Dim MyNamedRange    As Range
Dim rngAddress      As String
Dim rngColumnCount  As Long

On Error Resume Next
Set MyNamedRange = Range("Forecast")
On Error GoTo 0

If Not MyNamedRange Is Nothing Then
    rngAddress = MyNamedRange.Address
    rngColumnCount = MyNamedRange.Columns.Count
    If rngColumnCount > 254 Then
        Range(Split(rngAddress, ":")(0)).Resize(MyNamedRange.Rows.Count, 254).Name = "Excel_Fcast1A"
        Range(Split(rngAddress, ":")(0)).Offset(, 254).Resize(MyNamedRange.Rows.Count, rngColumnCount - 254).Name = "Excel_Fcast1B"
    End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

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