Hello All, I need some VBA help on a Program that Mr. Excel Posted on youtube:

Peter Corsa

New Member
Joined
May 5, 2022
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
This is the code in the VBA and I would like to get this code to sum up the numbers in each cell and I keep getting errors when I try to modify it. I set the a+1 = 84 for all but it gave errors. Then I set the Value = a & "-" = 84 and it did not work either. Can you please help? Thank you greatly and much appreciation!!!

Sub ListThemAll()
TC = 1
TR = 1
Ctr = 1
MaxRows = Rows.Count
EndCell = 7059052
Application.ScreenUpdating = False
For a = 1 To 39
For b = (a + 1) To 40
For c = (b + 1) To 41
For d = (c + 1) To 42
For e = (d + 1) To 43
For f = (e + 1) To 44

Cells(TR, TC).Value = a & "-" & b & "-" & c & "-" & d & "-" & e & "-" & f
Ctr = Ctr + 1
If Ctr Mod 25000 = 0 Then
ThisWorkbook.Save

End If
TR = TR + 1
If TR = MaxRows Then
TR = 1
TC = TC + 1
End If
Next f
Next e
Next d
Next c
Next b
Next a
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
The code from the video works. Why did you change it, and what is your intent?
 
Upvote 0
Combinations of what kind? The video code lists all 6-number combinations of the numbers 1 to 44. What do you want it to do. Be specific.
 
Upvote 0
Combinations of what kind? The video code lists all 6-number combinations of the numbers 1 to 44. What do you want it to do. Be specific.
Im sorry, I thought I was in the first post. I wanted to find all the combinations that totalled the number 84, (out of the 7 million that were displayed) Do you know how to do that?
 
Upvote 0
Whether you realize it or not, you are assuming readers of this post will know things they have no way of knowing unless you explain them. For example, you assume we know the combination size you want. You assume we know which errors you were getting. You assume we know which line of code is producing the errors. I'm out of time at the moment, but for the next person who attempts to help you, you might try to explain in this way:

"I would like to modify this the code to list all 'n'-number combinations of the numbers a to b."

Where 'n' is the combination size and 'a' & 'b' are the range of whole numbers.
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,085
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top