| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

Excel VBA 最初の空白でないセルを返す

提供: MyMemoWiki
2020年2月15日 (土) 08:19時点におけるPiroto (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

Excel VBA 最初の空白でないセルを返す

Excel VBAExcel

  1. Function FindFirst(cells As Range)
  2. Dim r As Long
  3. Dim c As Long
  4. Dim ret As Range
  5. Dim hit As Boolean
  6. hit = False
  7. For r = 1 To cells.Rows.Count
  8. For c = 1 To cells.Columns.Count
  9. If cells(r, c).Text <> "" Then
  10. Set ret = cells(r, c)
  11. hit = True
  12. Exit For
  13. End If
  14. Next
  15. If hit Then
  16. Exit For
  17. End If
  18. Next
  19. Set FindFirst = ret
  20. End Function