Action between massive selection in InputBox












0















I'm getting string array from InputBox with:



Set productName = Application.InputBox("Select products from list:", _
"Our dialog", , , , , , 8)


I want to color the cells, which I have chosen, after each choice.
For example, I want to select 10 cells (with one InputBox action).
I choose one (on this step I want to color this cell, to remember, that I have already chosen it), then press CTRL , choose second (color the cell), choose third (color the cell) etc.



Is it possible to make this with VBA?










share|improve this question

























  • You can choose all cells and colorize them in the end.

    – Pᴇʜ
    Nov 20 '18 at 10:12











  • I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

    – Alexey C
    Nov 20 '18 at 10:14











  • The cells you choose get highlighted already, is that not enough?

    – EvR
    Nov 20 '18 at 13:18
















0















I'm getting string array from InputBox with:



Set productName = Application.InputBox("Select products from list:", _
"Our dialog", , , , , , 8)


I want to color the cells, which I have chosen, after each choice.
For example, I want to select 10 cells (with one InputBox action).
I choose one (on this step I want to color this cell, to remember, that I have already chosen it), then press CTRL , choose second (color the cell), choose third (color the cell) etc.



Is it possible to make this with VBA?










share|improve this question

























  • You can choose all cells and colorize them in the end.

    – Pᴇʜ
    Nov 20 '18 at 10:12











  • I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

    – Alexey C
    Nov 20 '18 at 10:14











  • The cells you choose get highlighted already, is that not enough?

    – EvR
    Nov 20 '18 at 13:18














0












0








0








I'm getting string array from InputBox with:



Set productName = Application.InputBox("Select products from list:", _
"Our dialog", , , , , , 8)


I want to color the cells, which I have chosen, after each choice.
For example, I want to select 10 cells (with one InputBox action).
I choose one (on this step I want to color this cell, to remember, that I have already chosen it), then press CTRL , choose second (color the cell), choose third (color the cell) etc.



Is it possible to make this with VBA?










share|improve this question
















I'm getting string array from InputBox with:



Set productName = Application.InputBox("Select products from list:", _
"Our dialog", , , , , , 8)


I want to color the cells, which I have chosen, after each choice.
For example, I want to select 10 cells (with one InputBox action).
I choose one (on this step I want to color this cell, to remember, that I have already chosen it), then press CTRL , choose second (color the cell), choose third (color the cell) etc.



Is it possible to make this with VBA?







excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 11:04









Pᴇʜ

23.1k62950




23.1k62950










asked Nov 20 '18 at 10:08









Alexey CAlexey C

1335




1335













  • You can choose all cells and colorize them in the end.

    – Pᴇʜ
    Nov 20 '18 at 10:12











  • I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

    – Alexey C
    Nov 20 '18 at 10:14











  • The cells you choose get highlighted already, is that not enough?

    – EvR
    Nov 20 '18 at 13:18



















  • You can choose all cells and colorize them in the end.

    – Pᴇʜ
    Nov 20 '18 at 10:12











  • I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

    – Alexey C
    Nov 20 '18 at 10:14











  • The cells you choose get highlighted already, is that not enough?

    – EvR
    Nov 20 '18 at 13:18

















You can choose all cells and colorize them in the end.

– Pᴇʜ
Nov 20 '18 at 10:12





You can choose all cells and colorize them in the end.

– Pᴇʜ
Nov 20 '18 at 10:12













I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

– Alexey C
Nov 20 '18 at 10:14





I need to colorize after each selection, because i make selection from very big list and it's easy to confuse, what i have chosen and what - no

– Alexey C
Nov 20 '18 at 10:14













The cells you choose get highlighted already, is that not enough?

– EvR
Nov 20 '18 at 13:18





The cells you choose get highlighted already, is that not enough?

– EvR
Nov 20 '18 at 13:18












2 Answers
2






active

oldest

votes


















1














The answer to your question "Is it possible to make this with VBA" is: No it is not possible.



You cannot do this with only one InputBox but you can keep asking for a range selection until the user presses cancel.



Option Explicit

Public Sub ColorizeSelections()
Dim SelRange As Range
Dim ColorRange As Range

Do
On Error Goto CANCEL_LOOP 'next line throws error if cancel is pressed
Set ColorRange = Application.InputBox("Select products from list:", "Our dialog", , , , , , 8)
On Error GoTo 0 'always re-activate error reporting!!!

ColorRange.Interior.Color = vbGreen 'color new selected range

'remember all selected ranges in SelRange
If SelRange Is Nothing Then
Set SelRange = ColorRange
Else
Set SelRange = Union(SelRange, ColorRange)
End If

SelRange.Select 'select all previously selected ranges that were already colored.
Loop
CANCEL_LOOP:
'other stuff goes here
End Sub





share|improve this answer


























  • Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











  • @AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

    – Pᴇʜ
    Nov 20 '18 at 13:05



















1














Sub ran()
Dim stc As Range
Dim ytd As String
Do
On Error GoTo cc
Set stc = Application.InputBox("Selection", "Select range", Type:=8)

Dim cell As Range
stc.Interior.ColorIndex = 8
Loop
cc:
MsgBox ("Done")
Exit Sub
End Sub





share|improve this answer


























  • Please add some details........

    – Shoukat Mirza
    Nov 20 '18 at 10:52











  • Also Dim cell As Range and Dim ytd As String are pretty useless.

    – Pᴇʜ
    Nov 20 '18 at 10:55











  • Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390618%2faction-between-massive-selection-in-inputbox%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The answer to your question "Is it possible to make this with VBA" is: No it is not possible.



You cannot do this with only one InputBox but you can keep asking for a range selection until the user presses cancel.



Option Explicit

Public Sub ColorizeSelections()
Dim SelRange As Range
Dim ColorRange As Range

Do
On Error Goto CANCEL_LOOP 'next line throws error if cancel is pressed
Set ColorRange = Application.InputBox("Select products from list:", "Our dialog", , , , , , 8)
On Error GoTo 0 'always re-activate error reporting!!!

ColorRange.Interior.Color = vbGreen 'color new selected range

'remember all selected ranges in SelRange
If SelRange Is Nothing Then
Set SelRange = ColorRange
Else
Set SelRange = Union(SelRange, ColorRange)
End If

SelRange.Select 'select all previously selected ranges that were already colored.
Loop
CANCEL_LOOP:
'other stuff goes here
End Sub





share|improve this answer


























  • Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











  • @AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

    – Pᴇʜ
    Nov 20 '18 at 13:05
















1














The answer to your question "Is it possible to make this with VBA" is: No it is not possible.



You cannot do this with only one InputBox but you can keep asking for a range selection until the user presses cancel.



Option Explicit

Public Sub ColorizeSelections()
Dim SelRange As Range
Dim ColorRange As Range

Do
On Error Goto CANCEL_LOOP 'next line throws error if cancel is pressed
Set ColorRange = Application.InputBox("Select products from list:", "Our dialog", , , , , , 8)
On Error GoTo 0 'always re-activate error reporting!!!

ColorRange.Interior.Color = vbGreen 'color new selected range

'remember all selected ranges in SelRange
If SelRange Is Nothing Then
Set SelRange = ColorRange
Else
Set SelRange = Union(SelRange, ColorRange)
End If

SelRange.Select 'select all previously selected ranges that were already colored.
Loop
CANCEL_LOOP:
'other stuff goes here
End Sub





share|improve this answer


























  • Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











  • @AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

    – Pᴇʜ
    Nov 20 '18 at 13:05














1












1








1







The answer to your question "Is it possible to make this with VBA" is: No it is not possible.



You cannot do this with only one InputBox but you can keep asking for a range selection until the user presses cancel.



Option Explicit

Public Sub ColorizeSelections()
Dim SelRange As Range
Dim ColorRange As Range

Do
On Error Goto CANCEL_LOOP 'next line throws error if cancel is pressed
Set ColorRange = Application.InputBox("Select products from list:", "Our dialog", , , , , , 8)
On Error GoTo 0 'always re-activate error reporting!!!

ColorRange.Interior.Color = vbGreen 'color new selected range

'remember all selected ranges in SelRange
If SelRange Is Nothing Then
Set SelRange = ColorRange
Else
Set SelRange = Union(SelRange, ColorRange)
End If

SelRange.Select 'select all previously selected ranges that were already colored.
Loop
CANCEL_LOOP:
'other stuff goes here
End Sub





share|improve this answer















The answer to your question "Is it possible to make this with VBA" is: No it is not possible.



You cannot do this with only one InputBox but you can keep asking for a range selection until the user presses cancel.



Option Explicit

Public Sub ColorizeSelections()
Dim SelRange As Range
Dim ColorRange As Range

Do
On Error Goto CANCEL_LOOP 'next line throws error if cancel is pressed
Set ColorRange = Application.InputBox("Select products from list:", "Our dialog", , , , , , 8)
On Error GoTo 0 'always re-activate error reporting!!!

ColorRange.Interior.Color = vbGreen 'color new selected range

'remember all selected ranges in SelRange
If SelRange Is Nothing Then
Set SelRange = ColorRange
Else
Set SelRange = Union(SelRange, ColorRange)
End If

SelRange.Select 'select all previously selected ranges that were already colored.
Loop
CANCEL_LOOP:
'other stuff goes here
End Sub






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 13:05

























answered Nov 20 '18 at 10:46









PᴇʜPᴇʜ

23.1k62950




23.1k62950













  • Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











  • @AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

    – Pᴇʜ
    Nov 20 '18 at 13:05



















  • Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18











  • @AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

    – Pᴇʜ
    Nov 20 '18 at 13:05

















Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

– Alexey C
Nov 20 '18 at 12:18





Thank u. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

– Alexey C
Nov 20 '18 at 12:18













@AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

– Pᴇʜ
Nov 20 '18 at 13:05





@AlexeyC Then the answer to your question is: No it is not possible. • I improved my answer so you can mark it as solved.

– Pᴇʜ
Nov 20 '18 at 13:05













1














Sub ran()
Dim stc As Range
Dim ytd As String
Do
On Error GoTo cc
Set stc = Application.InputBox("Selection", "Select range", Type:=8)

Dim cell As Range
stc.Interior.ColorIndex = 8
Loop
cc:
MsgBox ("Done")
Exit Sub
End Sub





share|improve this answer


























  • Please add some details........

    – Shoukat Mirza
    Nov 20 '18 at 10:52











  • Also Dim cell As Range and Dim ytd As String are pretty useless.

    – Pᴇʜ
    Nov 20 '18 at 10:55











  • Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18
















1














Sub ran()
Dim stc As Range
Dim ytd As String
Do
On Error GoTo cc
Set stc = Application.InputBox("Selection", "Select range", Type:=8)

Dim cell As Range
stc.Interior.ColorIndex = 8
Loop
cc:
MsgBox ("Done")
Exit Sub
End Sub





share|improve this answer


























  • Please add some details........

    – Shoukat Mirza
    Nov 20 '18 at 10:52











  • Also Dim cell As Range and Dim ytd As String are pretty useless.

    – Pᴇʜ
    Nov 20 '18 at 10:55











  • Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18














1












1








1







Sub ran()
Dim stc As Range
Dim ytd As String
Do
On Error GoTo cc
Set stc = Application.InputBox("Selection", "Select range", Type:=8)

Dim cell As Range
stc.Interior.ColorIndex = 8
Loop
cc:
MsgBox ("Done")
Exit Sub
End Sub





share|improve this answer















Sub ran()
Dim stc As Range
Dim ytd As String
Do
On Error GoTo cc
Set stc = Application.InputBox("Selection", "Select range", Type:=8)

Dim cell As Range
stc.Interior.ColorIndex = 8
Loop
cc:
MsgBox ("Done")
Exit Sub
End Sub






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 10:50









GSerg

59.7k15103227




59.7k15103227










answered Nov 20 '18 at 10:38









Manoj BabuManoj Babu

312




312













  • Please add some details........

    – Shoukat Mirza
    Nov 20 '18 at 10:52











  • Also Dim cell As Range and Dim ytd As String are pretty useless.

    – Pᴇʜ
    Nov 20 '18 at 10:55











  • Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18



















  • Please add some details........

    – Shoukat Mirza
    Nov 20 '18 at 10:52











  • Also Dim cell As Range and Dim ytd As String are pretty useless.

    – Pᴇʜ
    Nov 20 '18 at 10:55











  • Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

    – Alexey C
    Nov 20 '18 at 12:18

















Please add some details........

– Shoukat Mirza
Nov 20 '18 at 10:52





Please add some details........

– Shoukat Mirza
Nov 20 '18 at 10:52













Also Dim cell As Range and Dim ytd As String are pretty useless.

– Pᴇʜ
Nov 20 '18 at 10:55





Also Dim cell As Range and Dim ytd As String are pretty useless.

– Pᴇʜ
Nov 20 '18 at 10:55













Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

– Alexey C
Nov 20 '18 at 12:18





Ty. I understand how to make it with lot of InputBoxes, but hoped, that it's possible with one.

– Alexey C
Nov 20 '18 at 12:18


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390618%2faction-between-massive-selection-in-inputbox%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)