ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inputbox macro for multiple cells (https://www.excelbanter.com/excel-programming/365178-inputbox-macro-multiple-cells.html)

mcphc

Inputbox macro for multiple cells
 
I would like to write a macro that asks the user to select multiple cells on
a sheet (i.e. D10,AK13,AG16,V19) using an InputBox or similar. Then I would
like the macro to cycle through each of the cells using the cell contents as
a string in some other statements.

Is this possible?

Thanks

Clayton

Ardus Petus

Inputbox macro for multiple cells
 
dim myRange as Range
Set myRange = Application.InputBox(prompt := "Sample", type := 8)

HTH
--
AP


"mcphc" a écrit dans le message de news:
...
I would like to write a macro that asks the user to select multiple cells
on
a sheet (i.e. D10,AK13,AG16,V19) using an InputBox or similar. Then I
would
like the macro to cycle through each of the cells using the cell contents
as
a string in some other statements.

Is this possible?

Thanks

Clayton




Ardus Petus

Inputbox macro for multiple cells
 
To browse thru multiple cells input:

'-------------------------------------------------------
dim myRange as Range
dim rCell as Range

Set myRange = Application.InputBox(prompt := "Sample", type := 8)
For each rCell in myRange

Next rCell
'---------------------------------------------------------

HTH
--
AP


"Ardus Petus" a écrit dans le message de news:
...
dim myRange as Range
Set myRange = Application.InputBox(prompt := "Sample", type := 8)

HTH
--
AP


"mcphc" a écrit dans le message de news:
...
I would like to write a macro that asks the user to select multiple cells
on
a sheet (i.e. D10,AK13,AG16,V19) using an InputBox or similar. Then I
would
like the macro to cycle through each of the cells using the cell contents
as
a string in some other statements.

Is this possible?

Thanks

Clayton






NickHK

Inputbox macro for multiple cells
 
Clayton,
Or for multiple selections:
Dim rng As Range
Dim Counter As Long
Dim Ranges() As String 'Or use an array of ranges

On Error Resume Next

Do
Set rng = Application.InputBox("Select a range, then click OK.", "Range
selection", , , , , , 8)
If Err.Number 0 Then Exit Do
Counter = Counter + 1
ReDim Preserve Ranges(1 To Counter)
Ranges(Counter) = rng.Address
Loop

NickHK

"mcphc" wrote in message
...
I would like to write a macro that asks the user to select multiple cells

on
a sheet (i.e. D10,AK13,AG16,V19) using an InputBox or similar. Then I

would
like the macro to cycle through each of the cells using the cell contents

as
a string in some other statements.

Is this possible?

Thanks

Clayton





All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com