大神,能否做个向上选择

随便聊聊 · 488 次浏览
EC10010 创建于 2022-05-14 00:14

先给大神点个赞👍

跟此动作相反的,请问向上选择怎么做呢


回复内容
湘喑 2022-05-14 10:05
#1

你这个需求好像不常用,我就不单独做动作了,你把代码修改为下面这段就可以了

代码我放另一楼了


湘喑 最后更新于 2022-05-14 10:09
EC10010 回复 湘喑 2022-05-14 10:19 :

谢谢大神

湘喑 2022-05-14 10:06
#2
Dim application,sh,rng
Set application = GetObject(,"excel.application")
Set sh = application.activesheet
set rng = application.selection
cols = rng.columns.count
If cols = sh.columns.count Then Set rng = application.intersect(rng,sh.usedrange)
r = rng.row
k = sh.rows.count
For i = 1 To cols
	If sh.cells(1,rng(1,i).column) <> "" Then
		k = 1
	else	
		j = sh.cells(1,rng(1,i).column).end(4).row
		If j <= r And j<k Then k = j
	End If	
Next
If k <> sh.rows.count Then sh.range(rng.offset(k - r),rng).select



Set application = Nothing
Set sh = nothing
set rng = nothing
湘喑 最后更新于 2022-05-14 10:08
阐幽探赜 2024-01-29 16:41
#3

大佬我又来了,想要一个【向右选择】,选到最后一列有数的地方。看了下代码,没看懂,只能拜托大佬写一下【向右选择】的代码了🤣🤣

回复主贴