回復 7#luhpro
luhpro前輩你好!
前輩!非常感激謝謝!再附檔案
Leov37-5,Leov37-51在2003應可以執行,將原填滿程式
Sub 填滿()
Dim E&, i&
Range("AB6") = ActiveCell '加入這一行開始列的參照位置
E = Cells(ActiveCell.Row, 1).End(xlDown).Row
Again:
ZZ = Application.InputBox("請輸入列數", "請輸入填滿間隔列數", 10, Type:=2)
If ZZ = "" Or ZZ = False Then End
Range("AB7") = ZZ '加入這一行間隔列數的參照數據
If ZZ <= 0 Then
MsgBox "列數間隔不得小於1列!!!", , "列數錯誤請重新輸入 !!"
GoTo Again
End If
For i = ActiveCell.Row To E Step ZZ
With Cells(i, 1).Resize(, 15).Interior
.ColorIndex = 34
End With
Next
Range("AB5") = 1 '加入這一行A欄的參照開關
End Sub
所以當資料改完後執行參照填滿
因為小弟能力不足,所以用拼湊的方式
先找到位置再執行填滿,就能解決困擾的問題
Sub IA()
清除填滿
HA
MA
參照填滿
Range("I3").Select
Range("I:I").EntireColumn.AutoFit
End Sub
Sub 參照填滿()
Dim E&, i&
找到位置
E = Cells(ActiveCell.Row, 1).End(xlDown).Row
For i = ActiveCell.Row To E Step Range("AB7")
With Cells(i, 1).Resize(, 15).Interior
.ColorIndex = 34
End With
Next
Range("AB5:AB7") = ""
End Sub
Sub 找到位置()
With Sheet1
Set c = Range("AB6")
Set Rng = .Cells.Find(Format(c, "0列"), LookIn:=xlValues, LookAt:=xlWhole)
.Select
If Not Rng Is Nothing Then Rng.Select
End With
End Sub
只是原本應該不需要如此複雜
無奈!!能力只有如此這般..!!
前輩能否簡化程式嗎?
希望有能力的前輩,請不吝賜教謝謝再三!!
小弟在此順祝各位前輩!
聖誕節快樂!!身體健康事事如意...作者: GBKEE 時間: 2010-12-25 11:46
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target(1), Range("A5:A152")) Is Nothing Then
If Target(1) <> "" And Range("AB5") = "" And Range("AB8") = "" Then 填滿
End If
If Not Intersect(Target(1), Range("H1:I2,M1:M2")) Is Nothing Then
If Range("AB5") = 1 Or Range("AB8") = 2 Then 清填滿
Range("AB5") = ""
Select Case Target(1).Address(0, 0)
Case "H1"
HA
Case "H2"
HB
Case "I1"
IA
Case "I2"
IB
Case "M1"
MA
Case "M2"
MB
End Select
End If
End Sub
複製代碼
作者: myleoyes 時間: 2010-12-27 21:18
回復 13#GBKEE
GBKEE良師你好!
良師!謝謝!辛苦囉!謝謝再三!!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target(1), Range("A5:A152")) Is Nothing Then
If Target(1) <> "" And Range("AB5") = "" And Range("AB8") = "" Then 填滿
End If
If Not Intersect(Target(1), Range("H1:I2,M1:M2")) Is Nothing Then
End If
Select Case Target(1).Address(0, 0)
Case "C1"
If Range("AB5") = 1 Or Range("AB8") = 2 Then 清填滿
Range("AB5") = ""
Case "H1"
HA
Case "H2"
HB
Case "I1"
IA
Case "I2"
IB
Case "M1"
MA
Case "M2"
MB
End Select
End Sub作者: GBKEE 時間: 2010-12-28 14:21