質問: 指定した範囲の数字の選択 エクセルで指定した範囲の中で1~5の数字のセルを検索して一度に選択したいのですが、どうすればいいのでしょうか。 教えて下さい。
回答: sub macrosel2() with selection.areas(1) with .cells(1, 1) irow_first = .row icolumn_first = .column end with irow_last = irow_first + .rows.count - 1 icolumn_last = icolumn_first + .columns.count - 1 end with dim eachcell as range, allcells as range for row = irow_first to irow_last step 1 bclmdel = true for clm = icolumn_first to icolumn_last step 1 bsel = false if (isnumeric(cells(row, clm).value)) then if (isempty(cells(row, clm).value) = false) then if ((0 <= cells(row, clm).value) and (cells(row, clm).value <= 5)) then bsel = true end if end if end if if (bsel) then if allcells is nothing then set allcells = cells(row, clm) else set allcells = application.union(allcells, cells(row, clm)) end if end if next clm next row allcells.select end sub