回答編集履歴
2
追記
test
CHANGED
@@ -111,3 +111,27 @@
|
|
111
111
|
|
112
112
|
|
113
113
|
```
|
114
|
+
|
115
|
+
追記2
|
116
|
+
|
117
|
+
実行している.xlsmファイルのある場所(フルパス)は
|
118
|
+
|
119
|
+
```VBA
|
120
|
+
|
121
|
+
Path =ThisWorkbook.Path
|
122
|
+
|
123
|
+
```
|
124
|
+
|
125
|
+
で取得できます。
|
126
|
+
|
127
|
+
またデスクトップへのフルパスは
|
128
|
+
|
129
|
+
```VBA
|
130
|
+
|
131
|
+
Dim Path As String, WSH As Variant
|
132
|
+
|
133
|
+
Set WSH = CreateObject("WScript.Shell")
|
134
|
+
|
135
|
+
Path = WSH.SpecialFolders("Desktop")
|
136
|
+
|
137
|
+
```
|
1
追記
test
CHANGED
@@ -53,3 +53,61 @@
|
|
53
53
|
実行後
|
54
54
|
|
55
55
|
![イメージ説明](a15764f0b58bc410e21408392bd9985f.png)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
追記
|
60
|
+
|
61
|
+
test1.xlsxとtest2.xlsmとする場合
|
62
|
+
|
63
|
+
開くファイルがtest1.xlsxになり、ShとThisShを入れ替えることになります。
|
64
|
+
|
65
|
+
```VBA
|
66
|
+
|
67
|
+
Sub tes2()
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
Dim Wb As Workbook
|
72
|
+
|
73
|
+
Dim Sh As Worksheet
|
74
|
+
|
75
|
+
Dim ThisSh As Worksheet
|
76
|
+
|
77
|
+
Dim Clo As Long
|
78
|
+
|
79
|
+
Dim Rws As Long
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
Set Wb = Workbooks.Open(Filename:="d:\test1.xlsx")
|
84
|
+
|
85
|
+
Set Sh = Wb.Sheets("Sheet1")
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Set ThisSh = ThisWorkbook.Sheets("Sheet1")
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
col = Sh.Range("1:1").Find(What:=ThisSh.Range("B22")).Column
|
94
|
+
|
95
|
+
Rws = Sh.Range("A:A").Find(What:=ThisSh.Range("A24")).Row
|
96
|
+
|
97
|
+
Sh.Cells(Rws, col).Value = ThisSh.Range("B24")
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
Set ThisSh = Nothing
|
102
|
+
|
103
|
+
Set Sh = Nothing
|
104
|
+
|
105
|
+
Set Wb = Nothing
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
End Sub
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
```
|