|
こんなでは?
Option Explicit
Public Sub Test()
' ●曜日表示処理
' Dim q As Long
Dim r As Long
' Dim s As Long
' Dim wkq As Date
Dim wkq As Long
' Dim wkqq As String
' Dim wkq1 As String
' Dim wkq2 As String
' Dim wkq3 As String
Dim wk2 As Variant
Dim wksMark As Worksheet
'月を年を入れて、"2010/8"の形で取得
wk2 = Application.InputBox(Prompt:="月を年を入れて、2010/8の形で入力", Type:=2)
If VarType(wk2) = vbBoolean Then
MsgBox "マクロがキャンセルされました", vbInformation
Exit Sub
End If
If Not IsDate(wk2) Then
MsgBox "入力値が指定形式として認めれません", vbInformation
Exit Sub
End If
'入力をシリアル値に変換
wk2 = DateValue(wk2)
'入力月の1日とする
wk2 = DateSerial(Year(wk2), Month(wk2), 1)
'入力月の前月末日を取得
wkq = wk2 - 1
' s = 1 '日の変数用
' r = 4 '表示する場所用
' wkq1 = wk2 '月を取得
' Sheets("シート").Select
' Range("a2").Select
Set wksMark = Worksheets("シート")
' Do Until s >= 32
'
' wkq2 = s
' wkq3 = "日"
'
' wkq = wkq1 + wkq2 + wkq3 '月日を取得
'
' Sheets("シート").Cells(2, r).FormulaR1C1 = "=text(weekday(wkq),""(aaa)"") " '式
'
' Sheets("シート").Cells(2, r).FormulaR1C1 = wkqq
'
' r = r + 1
' s = s + 1
'
' Loop
'入力月の1日から末日まで繰り返し
For r = 1 To Day(DateSerial(Year(wk2), Month(wk2) + 1, 0))
'曜日を代入
wksMark.Cells(2, r).Value = Format(wkq + r, "(aaa)")
' wksMark.Cells(3, r).Value = r '?????
Next r
Set wksMark = Nothing
End Sub
|
|