我正在尝试做一些看似简单的事情,但是在执行中存在一些问题。 假设我输入了特定的小时数和天数。然后,我想将这些小时数放在另一张纸上的每一天中,即如果输入5则为5天,如果输入3则为3天,依此类推。
Sheet A | Sheet B
|hours|days| | |monday|tuesday|wednesday|thursday|friday|saturday|sunday|
+--+-----+-+ | ++--++--++--++--++--++--++--++--++--++--+-++--++--++--++-+
| 8 | 5 | | | 8 | 8 | 8 | 8 | 8 | 0 | 0 |
任何输入都是无价的! p>
答案 0 :(得分:3)
如果在SheetA中有此
然后在SheetB中使用。将此公式放在A2中并复制
= IF(COLUMNS($ A2:A2)> SheetA!$ B $ 2,0,SheetA!$ A $ 2)
当您拖动公式时,COLUMNS公式将增加1,2,以此类推,因此公式中的6列将返回零。
答案 1 :(得分:0)
使用带有此代码的带有快捷方式或按钮的宏
Dim hours, days, Week as Range
Set hours = sheets(“YourSheetName”).range(“CellWithHours”)
Set days = sheets(“YourSheetName”).range(“CellWithDays”)
Set Week = sheets(“YourSheetName”).range(range(“CellWithMonday”), Range(“CellWithSunday”))
For i = 1 to days.value
Week.Cells(i).value = hours.value
Next i
For i = 1 to 7
If Week.Cells(i).value = “” then
Week.Cells(i).value = 0
End if
Next i