VBA Array Loop

40 pts.
Tags:
Array
FORALL loop
loop
VBA
Hello, Can anyone help me with VBA code that creates an array from a range of cells (A1:E1), loops through the array and performs a function. I already have the function now I need to create the array and loop. Thank you...

Software/Hardware used:
Excel VBA

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Why do you need the array ?You can use the cells range pretty much as an array.
    68,470 pointsBadges:
    report
  • ClaireJosie
    So how do I do that?
    40 pointsBadges:
    report
  • carlosdl
    Here's a short example. With this code, when you select any range of cells containing more than one cell, it will loop through the range, and will display something for each cell.  Take a look:Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim obj_Cell As Range If Target.Count > 1 Then For Each obj_Cell In Target.Cells With obj_Cell MsgBox "YourFunction(" & .Text & ")", vbInformation, "Col " & .Column & " " & "Row: " & .Row 'Put your function call here End With Next End If End Sub
    68,470 pointsBadges:
    report
  • carlosdl
    I don't seem to understand how this new editor works.  I will post the code alone in my next comment.
    68,470 pointsBadges:
    report
  • carlosdl
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)     Dim obj_Cell As Range     If Target.Count > 1 Then         For Each obj_Cell In Target.Cells             With obj_Cell                 MsgBox "YourFunction(" & .Text & ")", vbInformation, "Col " & .Column & " " & "Row: " & .Row                 'Put your function call here             End With         Next     End If End Sub
    68,470 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following