Show the value on the column depending on the given value from another column

mark692

Active Member
Joined
Feb 27, 2015
Messages
321
Office Version
  1. 2016
Platform
  1. Windows
I want a formula that i will put on remarks column, I want it to show the name of the leader from column "Leader" depending on what team the name belong. I have a sample table below. On my example team orange has a leader James thats why on the column remarks James appear depending on the coresponding team name from column "Team". thanks

Book1
ABC
1TeamLeaderRemarks
2OrangeJamesJames
3orangeJames
4orangeJames
5OrangeJames
6AppleMimiMimi
7AppleMimi
8AppleMimi
9GrapesLarryLarry
10GrapesLarry
11GrapesLarry
12GrapesLarry
Sheet1
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Are they always in order like that, with all like column A records being grouped together, and with column B always populated for the first record in each grouping?
If so, enter this formula in cell C2 and copy down for all rows:
Excel Formula:
=IF(B2<>"",B2,C1)
 
Upvote 0
Are they always in order like that, with all like column A records being grouped together, and with column B always populated for the first record in each grouping?
If so, enter this formula in cell C2 and copy down for all rows:
Excel Formula:
=IF(B2<>"",B2,C1)

no sir its not always on that order. the formula that you give changes the value when i change the order sir.
 
Upvote 0
no sir its not always on that order. the formula that you give changes the value when i change the order sir.
Could you please post a more realistic example of what your data looks like then?
 
Upvote 0
This is a portion of may table

on my sample column leader = Voucher No.
Team Column =Group code Column
Remarks column = Voucher No. Group

i want to put the formula on voucher no. Group thanks :)

Book1
ABCDEFGH
1Check Bankcheck no.check dateamountVoucher No.Group CodeVoucher No. GroupPosted On
2Metrobank38002803929/29/202018,235.711 SI11 SI10/29/2020
3164.2911 SI10/29/2020
411/7/20203,635.3021 DR10/30/2020
511/7/20201,349.7821 DR10/30/2020
6Metrobank380029700111/17/202038,338.971 DR21 DR10/30/2020
7Metrobank380029700211/18/202038,338.9721 DR10/30/2020
8Metrobank380029700311/19/202038,338.9721 DR10/30/2020
921 DR10/30/2020
1021 DR10/30/2020
11Metrobank380029700411/24/202022,086.502 DR32 DR10/30/2020
12Metrobank380029700511/25/202022,086.5032 DR10/30/2020
1332 DR10/30/2020
1432 DR10/30/2020
15Metrobank380029700610/20/202023,454.0842Si10/30/2020
1642Si10/30/2020
1742Si10/30/2020
1810/20/2020211.302Si42Si10/30/2020
192,279.463 SI53 SI10/30/2020
207/25/202020.5453 SI10/30/2020
21Metrobank380029700710/22/202027,561.694 SI64 SI10/30/2020
227/24/2020248.3064 SI10/30/2020
Sheet1
 
Upvote 0
Are we allowed to resort the data?
And are you open to a VBA solution?
 
Upvote 0
yes sir you can resort the data. yes VBA is ok if there is no formula for it.
 
Upvote 0
OK, I think this should do what you want:

VBA Code:
Sub MyMacro()

    Dim rng As Range
    Dim lr As Long
    
'   Find last row in column F with data
    lr = Cells(Rows.Count, "F").End(xlUp).Row
    
'   Set range of data to sort
    Set rng = Range("A2").CurrentRegion
    
'   Sort data by Group Code and Voucher No. fields
    rng.Sort key1:=Range("F1"), order1:=xlAscending, _
        key2:=Range("E1"), order2:=xlAscending, Header:=xlYes
    
'   Copy data from column E to column G
    Range("E2:E" & lr).Copy Range("G2")

'   Populate missing cells with in column G with value above
    Range("G2:G" & lr).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    Range("G2:G" & lr).Value = Range("G2:G" & lr).Value
    
End Sub
 
Upvote 0
OK, I think this should do what you want:

VBA Code:
Sub MyMacro()

    Dim rng As Range
    Dim lr As Long
   
'   Find last row in column F with data
    lr = Cells(Rows.Count, "F").End(xlUp).Row
   
'   Set range of data to sort
    Set rng = Range("A2").CurrentRegion
   
'   Sort data by Group Code and Voucher No. fields
    rng.Sort key1:=Range("F1"), order1:=xlAscending, _
        key2:=Range("E1"), order2:=xlAscending, Header:=xlYes
   
'   Copy data from column E to column G
    Range("E2:E" & lr).Copy Range("G2")

'   Populate missing cells with in column G with value above
    Range("G2:G" & lr).SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    Range("G2:G" & lr).Value = Range("G2:G" & lr).Value
   
End Sub
it works sir on the sample table i sent. ill try it now on my actual table thank you so much sir :)
 
Upvote 0

Forum statistics

Threads
1,214,527
Messages
6,120,054
Members
448,940
Latest member
mdusw

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