Could someone write a somewhat dummy down version of looping and integers guide? Been learning Vba on the fly and the this code makes me sick. No need to do all the work. I rather just have the tools to learn and do myself. I have been Googling non-stop and have had no luck on finding something to help me understand them.
*Sub Mapall_Click()* *'//all Destinations String* *Dim Start As String* *Dim Dst1 As String* *Dim Dst2 As String* *Dim Dst3 As String* *Dim Dst4 As String* *Dim Dst5 As String* *Dim Dst6 As String* *Dim Dst7 As String* *Dim Dst8 As String* *Dim Dst9 As String* *Dim Dst10 As String* *Dim Dst11 As String* *Dim Dst12 As String* *Dim Dst13 As String* *Dim Dst14 As String* *Dim Dst15 As String* *Dim Dst16 As String* *Dim Dst17 As String* *Dim Dst18 As String* *Dim Dst19 As String* *Dim Dst20 As String* *Dim Dst21 As String* *Dim Dst22 As String* *Dim Dst23 As String* *Dim FIN1 As String* *'//Set worksheet Google Map* *Dim wsMAP As Worksheet* *Set wsMAP = Sheets("GOOGLE MAP")* *'//Set worksheet Clients Routes* *Dim wsRoute As Worksheet* *Set wsRoute = Sheets("Routes")* *'//all Destinations String* *Start = wsRoute.Range("F6").Value '//Start* *Dst1 = wsRoute.Range("F7").Value '//Destination1* *Dst2 = wsRoute.Range("F8").Value '//Destination2* *Dst3 = wsRoute.Range("F9").Value '//Destination3* *Dst4 = wsRoute.Range("F10").Value '//Destination4* *Dst5 = wsRoute.Range("F11").Value '//Destination5* *Dst6 = wsRoute.Range("F12").Value '//Destination6* *Dst7 = wsRoute.Range("F13").Value '//Destination7* *Dst8 = wsRoute.Range("F14").Value '//Destination8* *Dst9 = wsRoute.Range("F15").Value '//Destination9* *Dst10 = wsRoute.Range("F16").Value '//Destination10* *Dst11 = wsRoute.Range("F17").Value '//Destination11* *Dst12 = wsRoute.Range("F18").Value '//Destination12* *Dst13 = wsRoute.Range("F19").Value '//Destination13* *Dst14 = wsRoute.Range("F20").Value '//Destination14* *Dst15 = wsRoute.Range("F21").Value '//Destination15* *Dst16 = wsRoute.Range("F22").Value '//Destination16* *Dst17 = wsRoute.Range("F23").Value '//Destination17* *Dst18 = wsRoute.Range("F24").Value '//Destination18* *Dst19 = wsRoute.Range("F25").Value '//Destination19* *Dst20 = wsRoute.Range("F26").Value '//Destination20* *Dst21 = wsRoute.Range("F27").Value '//Destination21* *Dst22 = wsRoute.Range("F28").Value '//Destination22* *Dst23 = wsRoute.Range("G28").Value '//Destination22* *FIN1 = wsRoute.Range("F6").Value '//Finish* *Dim Urlstring As String '//URL* *On Error GoTo Out* *'// Only 23 Destination* * If wsRoute.Range("G28").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" & Dst22 & "+to:+" _* * & Dst23 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* *'// Only 22 Destination* * If wsRoute.Range("F28").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" & Dst22 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 21 Destination* * If wsRoute.Range("F27").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & Dst19 & "+to:+" & Dst20 & "+to:+" & Dst21 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 20 Destination* * If wsRoute.Range("F26").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & Dst19 & "+to:+" & Dst20 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 19 Destination* * If wsRoute.Range("F25").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & Dst19 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 18 Destination* * If wsRoute.Range("F24").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" & Dst18 & "+to:+" _* * & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 17 Destination* * If wsRoute.Range("F23").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & Dst17 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 16 Destination* * If wsRoute.Range("F22").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & Dst16 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 15 Destination* * If wsRoute.Range("F21").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & Dst15 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 14 Destination* * If wsRoute.Range("F20").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & "+to:+" & Dst14 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 13 Destination* * If wsRoute.Range("F19").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & Dst13 & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 12 Destination* * If wsRoute.Range("F18").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & Dst12 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 11 Destination* * If wsRoute.Range("F17").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & Dst11 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 10 Destination* * If wsRoute.Range("F16").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & Dst10 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 9 Destination* * If wsRoute.Range("F15").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & Dst9 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 8 Destination* * If wsRoute.Range("F14").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & Dst8 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 7 Destination* * If wsRoute.Range("F13").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & Dst7 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 6 Destination* * If wsRoute.Range("F12").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" & Dst6 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 5 Destination* * If wsRoute.Range("F11").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & Dst5 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 4 Destination* * If wsRoute.Range("F10").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & Dst4 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 3 Destination* * If wsRoute.Range("F9").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & Dst3 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* *'// Only 2 Destination* * If wsRoute.Range("F8").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & Dst2 & "+to:+" _* * & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * Else* * '// Only 1 Destination* * If wsRoute.Range("G6").Value = True Then* * Urlstring = "http://maps.google.com/maps?q=" & Start & "+to:+" & Dst1 & "+to:+" & FIN1 & "&output=embed&iwloc=near"* * 'MsgBox (Urlstring)* * End If '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNN/:yo+ymNNNNNNNNNNNNNmmmmmmmmmmmmmmmmm* * End If '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNm sshmNNNNmyshNNm+hNmmmmmmmmmmmmmm* * End If ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNh: :/+osys++smNho NNNmmmmmmmmmmmmm* * End If ''''''''''''''''''''''''''''''''''''''' '''''''''''''''NNNNNNNNNNNNNNNNmo ://+++yyo dNNNmmmmmmmmmmmmm* * End If '''''''''''''''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNNNNy //++: oNNNNmmmmmmmmmmmmm* * End If '''''''''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNNNNNNh: :+y+ hNNNNmmmmmmmmmmm* * End If ''''''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNNNNNNmo yNNNNNmho dNNNNmmmmmmmmmm* * End If ''''''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNNNNNNNNNy hNNNNNNNNNNNhyNNNNmmmmmmmmmm* * End If ''''''''''''''''''''''''''''''NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmmmmmmmm* * End If '''* * End If '// Note to Self! THink its time to learn looping* * End If* * End If* * End If* * End If* * End If* * End If* * End If* * End If* * End If* * End If* *End If* *End If* * '// Finally if code has not got tired map destinations* * Sheets("GOOGLE MAP").WebBrowser1.navigate Urlstring* * Sheets("GOOGLE MAP").Select* *Exit Sub* *Out:* * MsgBox ("Error! Need Starting Point!")* *End Sub* -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/groups/opt_out.