Skip to content

Instantly share code, notes, and snippets.

View KotorinChunChun's full-sized avatar

KotorinChunChun KotorinChunChun

View GitHub Profile
@KotorinChunChun
KotorinChunChun / WScript.cls.vba
Last active March 25, 2023 17:10
VBEでVBSを編集するための偽WScriptクラス
Rem
Rem VBEでVBSを編集するための偽WScriptクラス
Rem
Rem 開発 : @KotorinChunChun
Rem
Option Explicit
Rem WScript オブジェクトのプロパティとメソッド
Rem https://docs.microsoft.com/ja-jp/previous-versions/windows/scripting/cc364456(v=msdn.10)
@KotorinChunChun
KotorinChunChun / vba_knock014.bas.vba
Created November 2, 2020 12:31
VBA100本ノック14本目
Option Explicit
'VBA100本ノック14本目
'出題を勘違いして答えた人の末路
Sub vba_knock14()
Dim wb As Workbook: Set wb = ActiveWorkbook
Dim ws As Worksheet
Dim moveWss As Variant: ReDim moveWss(0 To 0) '0はダミー
'削除すべきシートを特定
@KotorinChunChun
KotorinChunChun / vba_knock013.bas.vba
Created November 1, 2020 07:58
VBA100本ノック13本目
Option Explicit
'#VBA100本ノック 13本目
'選択セル(Selection:複数範囲あり)の文字列に「注意」という文字があった場合は、
'その「注意」の文字だけを"赤の太字"に設定してください。
'セル以外(図形等)が選択されている場合は何もせずに正常終了するようにしてください。
'※一部仕様を無視
' 図形選択前に選択していたセルを使ってでも絶対に処理を実行する
Sub vba_knock013()
@KotorinChunChun
KotorinChunChun / kccExtScience.bas.vba
Created October 31, 2020 05:13
選択中のセルの化学式の書式を整えるVBAマクロ
Rem 選択中のセルの化学式の書式を整えるVBAマクロ
Sub 選択範囲の化学式の書式を整える()
Dim MyRange As Range
Dim i As Integer
Dim s2 As String, s3 As String
Dim PHflg As Boolean
For Each MyRange In Selection
For i = 2 To Len(MyRange.Text)
s2 = Mid(MyRange.Text, i - 1, 2)
@KotorinChunChun
KotorinChunChun / BinaryFileIO.cls.vba
Created September 8, 2020 15:34
バイナリファイル読み書きラッパークラス
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "BinaryFileIO"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Rem --------------------------------------------------------------------------------
@KotorinChunChun
KotorinChunChun / MyClass.cls.vba
Created August 6, 2020 19:18
20200806_VBAのクラスでNewと同時に引数付きコンストラクタを起動する代替案
Option Explicit
Private name_
Private age_
Rem 標準モジュール用
Public Function Init1(pName, pAge) As MyClass
Set Init1 = Me
name_ = pName
age_ = pAge
@KotorinChunChun
KotorinChunChun / Test.bas
Last active July 25, 2020 20:55
20200725_配列の次元数に関係なく読み書きする関数
Option Explicit
Rem 動的に多次元配列のテストデータを生成するテスト
Sub Test_CreateTestArray()
Dim tStart As Single, tStop As Single: tStart = Timer
Dim i
For i = 1 To 1000
Dim arr
arr = CreateTestArray(1, 5, 4, 3, 4, 5)
@KotorinChunChun
KotorinChunChun / kccFuncExcelPartial.bas
Created June 24, 2020 14:35
20200624_確実にWorksheetのAutoFilterオブジェクトを返す関数
Rem --------------------------------------------------------------------------------
Rem
Rem @module kccFuncExcelPartial
Rem
Rem @description Excelオブジェクト操作関数
Rem
Rem @update 2020/06/24
Rem
Rem @author @KotorinChunChun (GitHub / Twitter)
Rem
@KotorinChunChun
KotorinChunChun / vbaquiz_20200517_AAA2ZZZ.bas
Last active May 19, 2020 15:32
VBAクイズ AAAをZZZまでインクリメントする
Option Explicit
'#VBAクイズ
'出典:http://www.excel.studio-kazu.jp/kw/20200517225250.html
'> AAAの値をAAB,AAC...AAZまでインクリメントし
'> 次のアルファベットを桁上げし、ABA,ABC?ZZZまで
'> 計算するコードを書きたい
'の解答
'https://twitter.com/KotorinChunChun/status/1262026213352026112?s=20
@KotorinChunChun
KotorinChunChun / FuncString_partial.bas
Created May 4, 2020 09:04
全ての文字に濁点を挿入する関数
Rem --------------------------------------------------
Rem ■kccFuncString
Rem 文字列変換関数 からの抜粋
Rem
Rem
Rem --------------------------------------------------
Option Explicit
Rem 文字列を一文字毎の配列に変換
Rem