in Education by
Below, I have code that sends a personalized SMS message and includes the name. I got that part to work. Now, I just need to make it so that my range is dynamic and moves down the respective column until there is no one left to message. In it's current state, it will only message the first person. I tried looking up dynamic range tutorials, loops, etc. but they were either too complex for me to grasp or would require me to rewrite what I already have working. Private Sub btnSend_Click() Dim contactNumberRange As Range Dim messageRange As Range Dim clientNameRange As Range Dim phoneCell As Range Dim messageCell As Range Dim nameCell As Range Set contactNumberRange = Range("D2") //Need to make this range dynamic Set messageRange = Range("E2") //This too Set clientNameRange = Range("A2") //This aswell For Each phoneCell In contactNumberRange For Each messageCell In messageRange For Each nameCell In clientNameRange SendMessage FROMPHONE, nameCell.Value, phoneCell.Value, messageCell.Value Next Next Next Me.Hide End Sub JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You just need to ammend your ranges with a last row variable. Also, qualify those ranges with a worksheet! Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") Dim LR As Long LR = ws.Range("A" & ws.Rows.Count).End(xlUp).Row Set contactNumberRange = ws.Range("D2:D" & LR) Set messageRange = ws.Range("E2:E" & LR) Set clientNameRange = ws.Range("A2:A" & LR) For Each phoneCell In contactNumberRange For Each messageCell In messageRange For Each nameCell In clientNameRange SendMessage FROMPHONE, nameCell.Value, phoneCell.Value, messageCell.Value Next nameCell Next messageCell Next phoneCell

Related questions

0 votes
    Below, I have code that sends a personalized SMS message and includes the name. I got that part to ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I am trying to adjust the row height based on the cell value. The operation have to run through ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have set up a new, empty, modeless userform, to fix my problem with the least amount of code ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am using a macro to write a formula into a cell on my Excel worksheet. The formula is written ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    I want to using sumifs function in VBA. And result paste in same column as previous data. JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I am trying to do some validation on the file name before it's saved. Here are my three file- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have a table: Using vba I need to add a column after UsedRange, add a header and fill cells ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have a table: Using vba I need to add a column after UsedRange, add a header and fill cells ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have a column array with the following values in my sheet: 11, 15, 5, 7, 2. I want to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have two sheets sheet1, sheet2. Sheet2 having the with records and duplicate number. like sheet1 1--- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have 10 worksheets. I want to create a table for each. every table has a different amount of ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    How do I transfer data from a worksheet to another based on a specific cell value? I tried several ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    We have over 10 computers on our network and everyone's computer opens up the file with no issue. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    How do I transfer data from a worksheet to another based on a specific cell value? I tried several ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
...