VBA - For Each Value I need help

MarioMagnus

New Member
Joined
Jul 8, 2021
Messages
14
Office Version
  1. 2019
Platform
  1. MacOS
Hi everyone,

I hope I can explain what kind of problem I am facing.
I have a table sheet 1, which contains the first name from row 5 in column A and in column B also from row 5 the last name.
Now I want to use For Each "Last Name" to run a loop that writes the first names for every exact same value (last name) on a new worksheet in cells one below the other.

As an an example:
In table sheet 1 in column A there are the first names Mike, Alice, Ron (there are also other first names) with all the same last names in column B e.g. Miller
Now the loop should write the individual first names one below the other on sheet 2 from line 2 onwards.

I use a ComboBox to select the surname, which only provides all surnames once.
The value of the ComboBox (i.e. the last name) is written on sheet 2 in cell A1.
I now somehow have to have every first name entered matching the last name in worksheet 2 from cell A2 to Ax.

I am unfortunately on the hose and have no idea how to implement it. Maybe you have a suggestion for me.

I hope you can help me.
Thanks and regards, Mario.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,951
Messages
6,122,446
Members
449,083
Latest member
Ava19

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