2021-01-01から1年間の記事一覧

経路検索

Sub ハイパーリンク挿入() Dim My_Site As StringDim i As Long For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row My_Site = "https://www.google.co.jp/maps/dir/" & Cells(i, 1) & "/" & Cells(i, 2) ActiveSheet.Hyperlinks.Add Anchor:=Cells(i, 3), Ad…

文字追加マクロ

Sub addString_Exe(n As Integer)'各セルの前後に文字を追加する Dim msg As String Dim strForward As String Dim strBack As String msg = "まず前方" & n & "文字目に追加する文字を入力して下さい。空欄でも構いません。" 'Application.InputBoxのType '…

実用マクロ集

SCマクロ Sub 指定範囲をクリア() Selection.ClearEnd SubSub 最終行へ() Cells(Rows.Count, Selection.Column).End(xlUp).SelectEnd Sub マクロ集 '最終行の取得Sub 最終行()Cells(Rows.Count, 1).End(xlUp).RowEnd Sub 'メッセージボックスMsgBox "おはよ…

目次作成マクロ

Sub makeSheetsContent()'シート目次を作る Dim arr As Variant Dim ws As Worksheet Dim rng As Range Dim buf As String Dim i As Integer Dim wsNum As Integer Call appSet wsNum = Worksheets.Count 'シートの数。見出しも作成するために1加えておく Re…

シート表示マクロ

Sub TEST() Dim WsName(1 To 3) As Variant Dim flag As Long Dim i As Long WsName(1) = "Sheet3" WsName(2) = "Sheet8" WsName(3) = "Sheet6" Dim WS As Worksheet For Each WS In Worksheets flag = 0 For i = 1 To 3 If WS.Name = WsName(i) Then flag =…

エクセルマクロ 合計まるめ

Sub 工種合計まるめ() Dim b As Long Dim i As Long Dim k As Long For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row If Cells(i, 1) <> "" Then Cells(i, 4) = WorksheetFunction.Sum(Range("F" & i, "J" & i)) b = Range("B" & i).Value k = -(Log(b) / L…

空白セルを消去上詰め、段落分け、列を挿入

Sub 空白行を上詰め() Selection.SpecialCells(xlCellTypeBlanks).Select Selection.Delete Shift:=xlUp End Sub Sub 整理() Selection.CurrentRegion.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp Columns("B:C").Insert Dim i As Long For i = 1 To…

段を挙げてそろえるマクロコード

段を挙げてそろえるマクロコード Sub ex() Dim i As Long Dim j As Long Application.ScreenUpdating = False If Cells(3, 3) <> "" Then Exit Sub For i = 3 To Cells(Rows.Count, 1).End(xlUp).Row If Cells(i, 1) <> "" Then For j = 3 To 4 Cells(i, j) …