Selecting a column then automatically deselecting values

diamondjoechubbs

New Member
Joined
Oct 26, 2020
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I am trying to recreate a macro to take a bunch of data and apply the same name to it where every line isn't automatically tagged. The first step is to have excel create a new column and import the name on the lines it is on and I have done that using the following formula =TRIM(IFERROR(RIGHT(B2,LEN(B2)-FIND(": ",B2)), "0")). Then I have a column that has the name followed by any number of blanks or spaces depending on how many fields of data that agent has. I have seen some way that you could select all the fields with a space and then tell it to start at the top and if it was blank to copy the field above it, but I am unable to recreate this step. I included a picture, but what I need it to do is automate filling in the rest of column S with the last value it sees above it.

1630624398794.png
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
What about just changing your existing formula to something like this?

21 09 03.xlsm
ST
1
2aEmployee: a
3a
4a
5a
6bEmployee: b
7b
8b
9b
10b
11b
12cEmployee: c
13c
14c
15c
16c
17c
Copy down
Cell Formulas
RangeFormula
S2:S17S2=IFERROR(TRIM(REPLACE(T2,1,FIND(":",T2),"")),S1)
 
Upvote 0
Can you explain to me how this works?
Sure.

=IFERROR(TRIM(REPLACE(T2,1,FIND(":",T2),"")),S1)


TRIM(REPLACE(T2,1,FIND(":",T2),""))
This takes the value in column T and replaces all characters from character 1 up to and including the colon with nothing, then trims the results as per your formula.
This is pretty similar to this part of your formula: RIGHT(T2,LEN(T2)-FIND(": ",T2)), I just thought the 'replace' was a bit more direct & neater.

So in cell S2 this produces the "a" as required.

In S3, this part of the formula produces an error because FIND(":", T3) fails and the IFERROR in my formula says in that case take the value from the cell above.
This produces another "a"
These errors keep occurring down the column and keep producing "a" from the cell above until the FIND does not produce an error which occurs in row 6 of my sample, producing a "b" there.

We could also have used your original formula and just replaced the red IFERROR part with the blue, like this
=TRIM(IFERROR(RIGHT(T2,LEN(T2)-FIND(": ",T2))," "))
=TRIM(IFERROR(RIGHT(T2,LEN(T2)-FIND(": ",T2)),S1))

Here it is with my same sample data

21 09 03.xlsm
ST
1
2aEmployee: a
3a
4a
5a
6bEmployee: b
7b
8b
9b
10b
11b
12cEmployee: c
13c
14c
15c
16c
17c
Copy down (2)
Cell Formulas
RangeFormula
S2:S17S2=TRIM(IFERROR(RIGHT(T2,LEN(T2)-FIND(": ",T2)),S1))
 
Upvote 0

Forum statistics

Threads
1,215,787
Messages
6,126,900
Members
449,348
Latest member
Rdeane

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