Excel公式将月份增加一个,每周增加一个月(Excel formula to increase month by one and week in month by one)
我需要一个公式来将月中的一周增加一个,并将月份增加一个。
基本上我需要一个遵循这种模式的正在进行的周一列表:
Month 1 2016, Week 1 2016, Monday = 4th Jan 2016 Month 2 2016, Week 2 2016, Monday = 8th Feb 2016 Month 3 2016, Week 3 2016, Monday = 21st Mar 2016 Month 4 2016, Week 4 2016, Monday = 25th Apr 2016 Month 5 2016, Week 1 2016, Monday = 2nd May 2016 Month 6 2016, Week 2 2016, Monday = 13th Jun 2016
I need a formula to increase the week in month by one as well as increase the month by one.
Basically I need an ongoing list of Mondays that would follow this pattern:
Month 1 2016, Week 1 2016, Monday = 4th Jan 2016 Month 2 2016, Week 2 2016, Monday = 8th Feb 2016 Month 3 2016, Week 3 2016, Monday = 21st Mar 2016 Month 4 2016, Week 4 2016, Monday = 25th Apr 2016 Month 5 2016, Week 1 2016, Monday = 2nd May 2016 Month 6 2016, Week 2 2016, Monday = 13th Jun 2016
原文:https://stackoverflow.com/questions/37941322
最满意答案
对于您似乎想要实现的目标,我建议使用
InStr
函数。InStr
将搜索一个字符串,并返回它首次出现的位置。 如果在搜索的字符串中没有搜索到的字符串,则返回0
。以下是它的使用方法:
InStr( [start], string, substring, [compare] )
一个工作示例c / o 网上技术 :
InStr(1, "Tech on the Net", "the") 'Result: 9' InStr("Tech on the Net", "the") 'Result: 9' InStr(10, "Tech on the Net", "t") 'Result: 15' InStr("Tech on the Net", "z") 'Result: 0'
For what you seem to be trying to achieve, I'd suggest using the
InStr
function instead.InStr
will search a string and will return the position where it first occurs. If the searched for string does not occur within the string being searched,0
will be returned.Here's how it's used:
InStr( [start], string, substring, [compare] )
A working example c/o Tech on the Net:
InStr(1, "Tech on the Net", "the") 'Result: 9' InStr("Tech on the Net", "the") 'Result: 9' InStr(10, "Tech on the Net", "t") 'Result: 15' InStr("Tech on the Net", "z") 'Result: 0'
相关问答
更多-
对于您似乎想要实现的目标,我建议使用InStr函数。 InStr将搜索一个字符串,并返回它首次出现的位置。 如果在搜索的字符串中没有搜索到的字符串,则返回0 。 以下是它的使用方法: InStr( [start], string, substring, [compare] ) 一个工作示例c / o 网上技术 : InStr(1, "Tech on the Net", "the") 'Result: 9' InStr("Tech on the Net", "the") 'Result: 9' InSt ...
-
改变这个: month = Worksheet(2).Cells(31, "J") 对此: month = Worksheet(2).Cells(31, "J").Value 和这个: Sheet1.Range("C" & num & ":C18") = 34 对此: For Each c in Worksheet(1).Range("C" & num & ":C18") c.Value = 34 Next c Change this: month = Worksheet(2).Cells(31 ...
-
你能在变量中保存公式的一部分吗? 然后调用Formula数组中的变量? 要节省字符? 所以简单地分开等式。 例如: var1 = DAY(EOMONTH(R1C,0)) 然后在公式中替换它。 对多个易于用变量替换的部件执行此操作。 Can you save parts of the formula in variables? And then call the variables in the Formula array? To save on characters? So simply split th ...
-
VBA运行时1004错误(VBA run-time 1004 error)[2022-07-14]
这对我有效... Sub Tester() Dim c As Range, cTot As Range, s As Series 'collect all values for "40" For Each c In Range("D1:D27").Cells If c.Offset(0, -1) = 40 Then If cTot Is Nothing Then Set cTot = c ... -
运行时错误'1004'(Run-Time error '1004')[2022-07-12]
在您的代码中,Col为零。 列从索引1开始,试试这个: Col = 1 'Set column format to number Columns(col).NumberFormat = "0" In your code Col is zero. Columns start from the index 1, Try this: Col = 1 'Set column format to number Columns(col).NumberFormat = "0" -
你的最后一行, Debug.Print wksPivotData.Range(1, 1).Value将不会打印,因为你错过了Range() 。 我想你想要A1? 使用Range(1,1) ,您指的是不存在的范围。 如果你想做单元格A1,你需要 With wksPivotData myData = .Range(.Cells(1,1),.Cells(1,1)).Value End with 由于您使用的是多个工作表,因此我将使用上面的with语句。 编写相同内容的另一种方法是wksPivotData. ...
-
VBA:从不同的工作表调用时运行时错误1004?(VBA: Run time error 1004 when called from different worksheet?)[2022-03-06]
我建议: Sub SUB_copyCtfColsToExtracted(sourceCol As Long, destCol As Long) sheetCTF.Range(sheetCTF.Cells(ctfHeadingRow, sourceCol), sheetCTF.Cells(ctfLastRow,sourceCol)).SpecialCells(xlCellTypeVisible).Copy _ Destination:=sheetEXTRACTED.Range(sheetEXTRACTED. ... -
设置名称的三个想法可能会失败: 您的工作簿中是否已有一张带有该名称的工作表? 尝试设置已在使用的名称将导致'1004' 也许您尝试设置的名称包含一些非法字符: : / \ * ? [ ] : / \ * ? [ ]是不允许的 也不允许使用空字符串或超过31个字符的字符串 Three ideas why setting the name might fail: Do you already have a sheet with that name in your workbook? Trying to set ...
-
我的VBA代码有一个命名范围的运行时错误#1004?(I get a Run-time Error #1004 for my VBA code with a Named range?)[2022-03-08]
尝试下面的代码,它将从“Tabelle1”表格中的单元格“A4:L37”创建“ggg”命名范围。 然后,它将另一个Range MyNamedRange设置为指定的Range("ggg") - 这个步骤不是必需的,我只想使用Range变量。 最后,它选择MyNamedRange 。 码 Sub SelectRange() Dim sourceBook As Workbook Dim sourceSheet As Worksheet Dim sourceSheetSum ... -
运行时错误1004(Run-time error 1004)[2022-06-14]
您没有正确限定所有范围 - 您需要限定所有Range和Cells调用,以便它们指定相同的工作表: Dim senaste As Range Sheets("PA").Range(Sheets("PA").Cells(senaste.Row, (senaste.Column - 2)), Sheets("PA").Cells(senaste.Row, senaste.Column)).Copy Worksheets("GL").Range(Worksheets("GL").Cells(3, 1), Work ...