Excel VBA: If Condition + Listing Names

Manucas

New Member
Joined
Jul 13, 2018
Messages
12
Hello. I need some help here.

Considerer the following image:
https://www.dropbox.com/s/aegrv5j83yjkurk/Test.png?dl=0

The idea is to click on the list of participants of Formation 1 (F.1) button and, from the column of formation 1, list the names of the trainees in the right table according to the group in which they are inserted ("G.1", "G.2", "G.3"), and so on. The name of the formation in the right table should also change depending on the list of participants button you click.


Imagining that I make changes in the left table and change a trainee from group 1 to group 2, i should have 1 of the following 2 options:

a) A warning message may appear saying that we should update the table because there were changes, and we clicking the button again to appear the new listing or;
b) The table is automatically updated according to the exchanges made (preferential).


Resuming, the code need to be able to define that, "If" a N fella is scheduled to "G.1", then the name is copied to the column of group 1, and so on.

I would appreciate your help.

Thank you in advance,
best regards
 
Click https://app.box.com/s/636tm5zhqfa1gchl7c70z1ee7de5xrg3here to download your file. Please note that I had to make a few changes. Use this version of the file. I have left a few empty cells in column F to give you an idea of how it works.

Mumps, that's all i wanted, you did a great job, and i appreciate a lot.

I just have one point that i would like to change, but the reason you did like that is my fault, because I expressed myself in the wrong way i think.

In the code you had done before, when you clicked in the list button, even if you had empty cells in the G column, it lists the other ones. This should happen because for a same column of a specific formation, not all people have to do or be a trainee.

Anyway, thank you very much for the work you've done, it's brutal and it helps me a lot already.

Thank you Sir
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Are you saying that you want all the names to appear even if column G for the name is blank? Please clarify in detail referring to specific cells and columns.
 
Upvote 0
Are you saying that you want all the names to appear even if column G for the name is blank? Please clarify in detail referring to specific cells and columns.

No Sir. What i iam trying to say is, imagining the following sittuations:

1. If we have all trainees with a group assigned (in column G - G.1/G.2/G.3), then, all of them are listed in the right table when you click the button to the respective formation, but;

2. If we just have a few ones with a group assigned and the other people none (empty cells in column G), then, just that ones are listed in the right table to the same formation.

If i weren't clear enought yet, please let me know

. And thank you one more time for the help.
 
Upvote 0
So you want only those with a group assigned in column G to be listed in the table on the right. Is that correct?
 
Upvote 0
So you want only those with a group assigned in column G to be listed in the table on the right. Is that correct?

Yes Sir, that's it.

Therefore, if the cells in column G, for each trainee, are empty, that trainee will not be listed to that specific formation
 
Upvote 0
Delete this part of the code from each of the 5 button macros:
Code:
For Each group In Range(Cells(6, button.Column + 1), Cells(LastRow, button.Column + 1))
        If group = "" Then
            MsgBox ("Please assign " & Range("D" & group.Row).Value & " to a group.")
            group.Select
            Application.ScreenUpdating = True
            Exit Sub
        End If
Next group
 
Upvote 0
Delete this part of the code from each of the 5 button macros:
Code:
For Each group In Range(Cells(6, button.Column + 1), Cells(LastRow, button.Column + 1))
        If group = "" Then
            MsgBox ("Please assign " & Range("D" & group.Row).Value & " to a group.")
            group.Select
            Application.ScreenUpdating = True
            Exit Sub
        End If
Next group

Mumps, you saved my life. Thank a lot, was a great help and i'm grateful for that.

If you come to Portugal just say something, i pay you some drinks ;D

Best Regards
 
Upvote 0
You are very welcome and thank you for the offer. :beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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