Loop through specific range and copy values to another sheet if condition is met

  • Thread starter Thread starter Legacy 489849
  • Start date Start date
L

Legacy 489849

Guest
Dear internet,

I am currently building an Excel tool for my bachelor's thesis and I am kinda lost as I seem to stupid to figure out (to me) more complex VBA. This is like the last thing I need to be done with this tool, so help is highly appreciated!
smile.gif


So I have a sheet (INPUT DATA) with the structure as shown in the Excel file attached. The aim is to basically get a report with two lists based on conditions met in column B and C with content from column D and E in another sheet (OUTPUT DATA). It should indicate all measures a user has not fulfilled yet in two categories "Mandatory measures" and "Recommended measures".

Which measures are recommended and which ones mandatory changes dynamically based on user input. The idea is to have the user click a button once he is done with all input (which is basilly filling out a questionnaire ticking boxes with yes/no where I do some clean up of input), so the list is fully set up with no more changes to generate the report with the two lists.

My idea was to loop through every row and check first: if B (Done?) = FALSE and C (Category) = Mandatory --> place cell value from D (Headline) in next empty cell and E (Text) in the one following
Until there are no more cells in INPUT DATA filled with values (which is about 100 rows in total)

Once done for all mandatory measures, same should be done for the recommended measures with a headline indicating the change in between (see OUTPUT DATA for inteded formatting). So again if B (Done?) = FALSE and C (Category) = Recommended --> place cell value from D (Headline) in next empty cell in OUTPUT DATA list and E (Text) in the one following

I have googled quite a qhile and watched some tutorials on VBA, but hell, I just can't figure it out
frown.gif
- thank you very much!

The INPUT SHEET looks smiliar to this:

Excel_VBA_Dynamically get values from sheet to another (1).xlsx
ABCDE
1User inputDone?CategoryHeadlineText
2YesWAHRRecommendedUse of passwordsUse passwords.
3NoFALSCHMandatoryLockable roomsLock rooms.
4NoFALSCHRecommendedFire detectionGet some fire protection.
5YesWAHRMandatoryDo stuffDo something else
6NoFALSCHMandatoryDo more stuffDo another thing
7NoFALSCHRecommendedHave a good timeEnjoy your day
8
INPUT DATA
Cell Formulas
RangeFormula
B2:B7B2=IF(A2="Yes", TRUE, FALSE)
Cells with Data Validation
CellAllowCriteria
A2:A8ListYes; No


The OUTPUT SHEET should be something like this:

Excel_VBA_Dynamically get values from sheet to another (1).xlsx
ABCDEFG
1Click this button once you are done for your report:Some Excel Button to trigger Macro running
2
3
4The following measures MUST be taken into account:
5Lockable rooms
6Lock rooms.
7Do more stuff
8Do another thing
9
10The following measures SHOULD be talken into account:
11Fire detection
12Get some fire protection.
13Have a good time
14Enjoy your day.
15
16
OUTPUT DATA
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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