excel - 使用多项选择创建多个命名范围
问题描述
我只是用这个代码得到一个名字范围,我的错是什么?
任何帮助,我的语言太糟糕了,对不起!
Sub Create_Names()
Worksheets("DATA").Activate
Dim rng As Range
With ActiveSheet
Set rng = Range("J2:J10, J47:S67")
End With
rng.Select
With Selection
'Set rng = Selection
Dim i As Integer
Dim n As Long
Dim new_range As Range
Dim col_num As Integer
Dim first_Row As Long
Dim last_row As Long
For i = 1 To rng.Columns.Count
For n = rng.Rows.Count To 1 Step -1
col_num = rng.Columns(i).Column
first_Row = rng.Rows(1).Row
last_row = rng.Rows(n).Row
If Cells(last_row, col_num).Value <> "" Then
Set new_range = Range(Cells(first_Row, col_num), Cells(last_row, col_num))
new_range.CreateNames Top:=True
Exit For
End If
Next n
Next i
End With
End Sub
我有一个大数据,我想创建一次名称范围以使其简单..请帮助我..
我改变我的代码和它的工作就像我想要的..
for each rng in Application.Selection.Areas
'i run the code here
next rng
创建名称有限制吗?
我放的时候出错了
Set rng = Range("J2:J10, J47:S67,V47:BI77,BL1:BL21,CB35:CU64,CB120:FW170,CX20:MM35,CX51:EU61")
解决方案
推荐阅读
- c# - 如何从抽象类中构造当前的具体类型?
- react-native - 如何从 React Native 访问健康数据
- r - 裁剪和屏蔽拉斯塔数据并将其转换为矢量
- flutter - 有没有办法在调试 Flutter App 时更改值
- java - 为什么“购物车”属性没有更新?如何在网站上发送通知?
- python - 如何使用 for 循环内联 false true discord bot python 嵌入
- java - 使用 Oozie Java API 在 Apache oozie 中获取正在运行的协调器作业的所有工作流
- android - 仅对使用 koin 的两个片段使用 SharedViewModel
- python - 我正在网页抓取,试图在网站页面上获取一组 url,但是我收到了错误
- python - 取消在执行器中运行的异步任务