.
乾隆初年,大金川日益强盛,该土司头目莎罗奔兴兵攻打小金川,劫持了土司泽旺及其印信。不久,又出兵攻掠革布什札、明正两土司。为了惩治大金川对邻部的侵犯,乾隆十二年(1747年),乾隆帝调动三万大军,分两路进攻大金川。[40-43] 然而,由于当地山势险峻、气候恶劣等许多原因,直到乾隆十三年(1748年)夏秋,清军仍然没有取得什么进展。乾隆帝势同骑虎,又增兵增饷, [44] 特派大学士傅恒前往该地指挥作战。[45] 傅恒至军后,采取了岳钟琪选锐深入的作战方略。[46-47] 乾隆十四年(1749年)二月,清军进逼莎罗奔老巢勒乌围,莎罗奔被迫乞降。[48-49]
yhd-ExcelVBA End属性查找”最后”的单元格
'Range.End 属性
'返回一个 Range 对象,该对象代表包含源区域的区域尾端的单元格。
'等同于按键 (End 向上键、End 向下键、End 向左键、End 向右键),或者CTRL 上下左右
'语法
'表达式.End (Direction)
'表达式 一个代表 Range 对象的变量。
' Direction写法 值
'向上 xlUp '向下 xlDown '向左 xlToLeft '向右 xlToRight
===测试代码1===
Sub test1()
Range('D7').End(xlDown).Select
Range('D7').End(xlUp).Select
Range('D7').End(xlToRight).Select
Range('D7').End(xlToLeft).Select
End Sub
可以看到分别是一个区域的上下左右“最边”的单元格
===测试代码2===
===取得最后一个单元格===
Sub 最后的单元格()
With Sheets('test3')
a = Cells(Rows.Count, 1).End(xlUp).Row 'end属性
b = Columns(1).Find('*', , , , , xlPrevious).Row 'find方法
c = Cells.SpecialCells(xlCellTypeLastCell).Row 'specialcells方法
d = Sheet1.UsedRange.Rows.Count 'usedrange属性
e = [a1].CurrentRegion.Rows.Count 'currentregion属性
f = WorksheetFunction.CountA([a:a]) '工作表函数counta
g = Application.CountIf([a:a], '<>') '工作表函数countif
End With
End Sub
===测试代码3===
'如果数据是连续性的不间断的就用这个
Sub test3()
With Sheets('test3')
en = Cells(Rows.Count, 1).End(xlUp).Row
For i = 3 To en
col = Cells(i, 1).End(xlToRight).Column
Cells(i, 'V') = Cells(2, col).Value
Next i
End With
End Sub
'如果数据有间断不连续的就用以下
Sub test32()
With Sheets('test3')
en = Cells(Rows.Count, 1).End(xlUp).Row
For i = 3 To en
col = Cells(i, Columns.Count).End(xlToLeft).Column
Cells(i, 'V') = Cells(2, col).Value
Next i
End With
End Sub