回答編集履歴

2

修正(どんどん長くなる…)

2017/03/15 07:49

投稿

ttyp03
ttyp03

スコア16998

test CHANGED
@@ -22,13 +22,23 @@
22
22
 
23
23
  ```VBA
24
24
 
25
- With Cells(2, 1)
25
+ With Cells(1, 1)
26
26
 
27
27
  If .Hyperlinks.Count > 0 Then
28
28
 
29
29
  sd = Split(.Hyperlinks.Item(1).SubAddress, "!")
30
30
 
31
+ For Each ws In Worksheets
32
+
33
+ If ws.Name = sd(0) Then
34
+
31
- Debug.Print Worksheets(sd(0)).Index
35
+ Debug.Print ws.Index
36
+
37
+ Exit For
38
+
39
+ End If
40
+
41
+ Next
32
42
 
33
43
  End If
34
44
 

1

エラー処理追加

2017/03/15 07:49

投稿

ttyp03
ttyp03

スコア16998

test CHANGED
@@ -15,3 +15,23 @@
15
15
  Cellsの位置は適宜修正してください。
16
16
 
17
17
  またエラー処理もしていないので、適当に修正願います。
18
+
19
+
20
+
21
+ エラー処理あり版
22
+
23
+ ```VBA
24
+
25
+ With Cells(2, 1)
26
+
27
+ If .Hyperlinks.Count > 0 Then
28
+
29
+ sd = Split(.Hyperlinks.Item(1).SubAddress, "!")
30
+
31
+ Debug.Print Worksheets(sd(0)).Index
32
+
33
+ End If
34
+
35
+ End With
36
+
37
+ ```