teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

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

2017/03/15 07:49

投稿

ttyp03
ttyp03

スコア17002

answer CHANGED
@@ -10,10 +10,15 @@
10
10
 
11
11
  エラー処理あり版
12
12
  ```VBA
13
- With Cells(2, 1)
13
+ With Cells(1, 1)
14
14
  If .Hyperlinks.Count > 0 Then
15
15
  sd = Split(.Hyperlinks.Item(1).SubAddress, "!")
16
+ For Each ws In Worksheets
17
+ If ws.Name = sd(0) Then
16
- Debug.Print Worksheets(sd(0)).Index
18
+ Debug.Print ws.Index
19
+ Exit For
20
+ End If
21
+ Next
17
22
  End If
18
23
  End With
19
24
  ```

1

エラー処理追加

2017/03/15 07:49

投稿

ttyp03
ttyp03

スコア17002

answer CHANGED
@@ -6,4 +6,14 @@
6
6
  ```
7
7
 
8
8
  Cellsの位置は適宜修正してください。
9
- またエラー処理もしていないので、適当に修正願います。
9
+ またエラー処理もしていないので、適当に修正願います。
10
+
11
+ エラー処理あり版
12
+ ```VBA
13
+ With Cells(2, 1)
14
+ If .Hyperlinks.Count > 0 Then
15
+ sd = Split(.Hyperlinks.Item(1).SubAddress, "!")
16
+ Debug.Print Worksheets(sd(0)).Index
17
+ End If
18
+ End With
19
+ ```