问题描述
我正在通过Excel 2007进行数据分析 MACRO。 因为我想得到一张表的列数, 我选择 获取它的Activsheet.UsedRange.Column.Count。 请按以下方式查找脚本:
I'm working on a data analysis MACRO via Excel 2007. Since I want to get the columns count of one sheet, I choose Activsheet.UsedRange.Column.Count to get it. Please find the script as following lines:
//开始
xlsSheetContinuousServiceVertical.Activate
intColumnCount_ContinuousService_Vertical = xlsSheetContinuousServiceVertical.UsedRange.Columns.Count
strLastColumnName_ContinuousService_Vertical = Split(xlsSheetContinuousServiceVertical.Cells(1,intColumnCount_ContinuousService_Vertical).Address," $")(1)
xlsSheetContinuousServiceVertical.Columns(" A:"& strLastColumnName_ContinuousService_Vertical)。删除(xlShiftToLeft)
xlsSheetContinuousServiceVertical.Activate
intColumnCount_ContinuousService_Vertical = xlsSheetContinuousServiceVertical.UsedRange.Columns.Count
strLastColumnName_ContinuousService_Vertical = Split(xlsSheetContinuousServiceVertical.Cells(1, intColumnCount_ContinuousService_Vertical).Address, "$")(1)
xlsSheetContinuousServiceVertical.Columns("A:" & strLastColumnName_ContinuousService_Vertical).Delete (xlShiftToLeft)
intColumnCount_ContinuousService_Vertical = xlsSheetContinuousServiceVertical.UsedRange.Columns.Count
intColumnCount_ContinuousService_Vertical = xlsSheetContinuousServiceVertical.UsedRange.Columns.Count
MsgBox intColumnCount_ContinuousService_Vertical
MsgBox intColumnCount_ContinuousService_Vertical
//结束
每当我重新打开excel文件时,它运行良好,但是,如果我第二次运行Marco,我注意到了intColumnCount_ContinuousService_Vertical> 1. 
Everytime I reopen the excel file, It runs well, However, If I run the Marco second time , I noticed intColumnCount_ContinuousService_Vertical > 1.
请指导我如何完全删除"UsedRange"表格中的区域?
Please guide how can I completly delete "UsedRange" Area in the sheet?
推荐答案
这篇关于请指导如何在Excel 2007中完全删除UsedRange?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!