エクセルでは=round(12345,-2) 12300になるがVBAではエラーになる
WorksheetFunction.Round((mydata(i, 2) * 1.1), -2)
を使えば可能だがスピードは落ちる
課税給与所得金額 = (Int(課税給与所得金額 / 1000)) * 1000
Dim rc As Long
rc = MsgBox("現金シートがすべて消えますがよろしいですか", vbYesNo + vbCritical)
If rc = vbYes Then
MsgBox "jikkou "
End If
=RIGHT(CELL("filename",A1),LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1)))
エクセルはand(sname <> "", RTrim(sname) <> "AA")
If (sname <> "" And RTrim(sname) <> "AA") Then
Worksheets("元帳").Cells(i, 17) = Format(tukikeir, "#,###")
msheet = Worksheets("メニュー").Cells(7, 14)
msheetは2012/1/1
mtuki = Month(msheet)
Cells(i, 3)が日付の場合
Select Case Cells(i, 3)
Case Is <= CDate("2013/12/ 31")
Dim tmp As String, CL As String
CL = Chr(13) & Chr(10)
tmp = "明日は" & DateAdd("d", 1, Date) & "です" & CL
tmp = tmp & "1週間後は" & DateAdd("ww", 1, Date) & "です" & CL
tmp = tmp & "1ヶ月後は" & DateAdd("m", 1, Date) & "です" & CL
tmp = tmp & "3年後は" & DateAdd("yyyy", 3, Date) & "です"
MsgBox tmp
Dim hidukes As String
Dim hidukee As String
Dim hajimes As Date
Dim hajimee As Date
hidukes = "21 221"
hidukee = "21 329"
hajimes = CDate(1988 + Mid(hidukes, 1, 2) & "/" & Mid(hidukes, 3, 2) & "/" & Mid(hidukes, 5, 2))
hajimee = CDate(1988 + Mid(hidukee, 1, 2) & "/" & Mid(hidukee, 3, 2) & "/" & Mid(hidukee, 5, 2))
MsgBox hajimee - hajimes
空白を作る関数
MsgBox space(10) & Cells(1, 1)
Cells(2, 3) = UCase(Cells(2, 1))
Cells(3, 3) = LCase(Cells(3, 1))
Cells(4, 2) = StrConv(Cells(4, 1), vbNarrow)
cells(1,1)=2012/1/3で日付表示の場合
文字列のため2012/01/03でデータが入っている
msgbox left(cells(1,1),7)
2012/01
cells(1,1)=2012/1/3で日付表示の場合
文字列のため2012/01/03でデータが入っている
msgbox right(cells(1,1),2)
03
cells(1,1)=2012/1/3で日付表示の場合
文字列のため2012/01/03でデータが入っている
msgbox mid(cells(1,1),5,2)
/0
Dim data As String
Dim nagasa As Long
data = "abcdef.xlsx"
nagasa = Len(data)
data = Mid(data, 1, nagasa - 5)
MsgBox data
abcdef
MsgBox InStr("大阪市阿倍野区", "市")
Dim tiku As String
tiku = InputBox("地区?")
Cells(1, 5) = tiku
amari = (支払金額 - 1619000) Mod 1000
Select Case Len(txthiduke.Text)
Case 0 To 2
MsgBox "桁数が少ない(12/3)"
Exit Sub
Case 6 To 7
MsgBox "桁数が少ない(2012/12/3) "
Exit Sub
Case Is >= 11
MsgBox "桁数が多い "
Exit Sub
End Select
Sub kensu()
MsgBox Len(ActiveCell)
End Sub
If IsNumeric(txtkingaku.Text) = False Then
MsgBox "数字以外です"
Exit Sub
End If
Dim youbino As Long
Dim nentuki As String
nentuki = "2013/11/1"
youbino = Weekday(nentuki)
Dim youbimei As String
Dim nentuki As String
nentuki = "2013/11/1"
youbimei = WeekdayName(Weekday(nentuki))
"【" & Format(流動資産, "#,###") & "】"
Dim kingaku As Double
kingaku = Application.WorksheetFunction.Pmt(Val(txtrisoku.Text) / 1200, Val(txtkikan.Text), Val(txtkingaku.Text), 0)
txthensai.Text = kingaku * -1
txthensai.Text = Format(txthensai.Text, "#,##0")
txtkingaku.Text = Format(txtkingaku.Text, "#,##0")
Dim 文字型連番 as String
Dim 番号 as Long
番号=3
文字型連番=MID(番号+100,2,2)
BJ2をcells(2,62)に変換する
Dim moji As String
moji = "cells(" & Range("BJ2").Row & "," & Range("BJ2").Column & ")"
MsgBox moji)
Dim 生年月日 As Date
Dim 年令 As Long
生年月日 = "1953/3/31"
年令 = DateDiff("yyyy", 生年月日, Date)
MsgBox 年令
Dim i As Long
For i = 258 To 267
Cells(i, 2) = Replace(Cells(i, 2), "浅井", "山本")
Cells(i, 3) = Replace(Cells(i, 3), "アサイ", "ヤマモト")
Next