help with column looping

new2vba

Board Regular
Joined
Aug 15, 2006
Messages
146
i have multiple columns with a name followed by five #'s as such:

Name
#1
#2
#3
#4
#5

i'm want to loop through each column, and when criteria are met (ex:#4>#1), copy that column to another location and sort the numbers. i have a problem thinking in vba code, and i can't figure out how to code this logic:

for each column b to e, if row 5>row2 then....

the copy and sort which follows i think i got. Any ideas?
 
something changed though...it is leaving out the first number in the sort...let me see if i can figure out why
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
the results im getting consistenly put name, the first number, and then numbers 2 - 5 sorted. now that i think about the numbers i gave you last night from home (made up numbers) i can see how it would be hard to tell (they were equal in many cases)
 
Upvote 0
The results I'm getting are correct no matter how I change the numbers. Have you changed anything or are you still using it as it is in my previous post?
 
Upvote 0
ive tried your new code, then i went back to the old code and tried that...the only thing different is the actual numbers - but it consistently puts the first number, then sorts the other four below
 
Upvote 0
okay, got it...ive made a change, coloring the background of all the rows except the first row of numbers, this keeps it from sorting for some reason
 
Upvote 0
ive tried a few times...once i change the background color of any row...it stops sorting the 1st nnumber
 
Upvote 0
Nothing else has changed? So far, I haven't been able to reproduce the problem. There must be a reason. We'll find it.

Maybe, you could send me the file again. Let me know, here, if you do. I'll be more than glad to take another look.

Mac
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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