Re: [算表] vba一行改成多行

看板Office作者 (可愛小孩子)時間11月前 (2023/05/31 08:43), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
如圖: https://imgur.com/4BS1dAV
C2公式(下拉右拉): =REPT("V",(MOD(MAX(C$1-$B2,),3)=2)*(C$1<$A2*3+$B2)) ※ 引述《instarfree (Elisa)》之銘言: : 軟體:excel : 版本:2019 : 使用chatgpt寫VBA : 只寫一行是正確的 : 請他運算整張算表就開始錯誤連篇.. : 希望版上大大協助 : Sub FillVBasedOnOffset() : Dim rngNumbers As Range : Dim rngOutput As Range : Dim targetNumber As Integer : Dim outputCount As Integer : ' 設置數字範圍和輸出範圍 : Set rngNumbers = Range("I1:AL1") : Set rngOutput = Range("I2:AL2") : ' 儲存 H2 的數值 : Dim h2Value As Variant : h2Value = Range("H2").Value : ' 清空輸出範圍 : rngOutput.ClearContents : ' 獲取目標數字和輸出次數限制 : targetNumber = Range("H2").Value + 2 : outputCount = Range("B2").Value : ' 填充V : For Each cell In rngNumbers : If cell.Value = targetNumber Then : If outputCount > 0 Then : cell.Offset(1).Value = "V" : outputCount = outputCount - 1 : End If : targetNumber = targetNumber + 3 : End If : Next cell : ' 恢復 H2 的數值 : Range("H2").Value = h2Value : End Sub : https://imgur.com/44RX0oR
: 實際用VBA操作後2列是正確的 : 如何改成可以運行在第2列~第58列 : 目標 : 開始日期+2則打V 之後每個三天打V(打勾日期+3) : 打勾的次數不超過B欄的數字 : 如果有可以用公式的解法更好(可以在googlesheet上執行) : 但是CHATGPT寫不太出來... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 136.226.241.106 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Office/M.1685493822.A.F51.html
文章代碼(AID): #1aTfW-zH (Office)
討論串 (同標題文章)
文章代碼(AID): #1aTfW-zH (Office)