Macro help

Alisya

Well-known Member
Joined
Nov 27, 2008
Messages
532
Hi, i need a macro that will produce result as shown in Col B, thus i want the code to create a reference for each set of Groups, i do have amounts in Col C.

Excel Workbook
AB
6GroupRef
7NOMSNO0001
8NOMSNO0002
9NOMSNO0003
10NOMSNO0004
11NOMSNO0005
12NOMSNO0006
13NOMSNO0007
14LIFELI0001
15LIFELI0002
16LIFELI0003
17LIFELI0004
18LIFELI0005
19LIFELI0006
20LIFELI0007
21LIFELI0008
22LIFELI0009
23JPMCASHETC
24JPMCASH
25JPMCASH
26JPMCASH
27JPMCASH
28CITICASH
29CITICASH
30CITICASH
Sheet3
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try the formulas in C2 and B2 copied down

Excel Workbook
ABC
1GroupRefNos
2NOMSNO00011
3NOMSNO00022
4NOMSNO00033
5NOMSNO00044
6NOMSNO00055
7NOMSNO00066
8NOMSNO00077
9LIFELI00011
10LIFELI00022
11LIFELI00033
12LIFELI00044
13LIFELI00055
14LIFELI00066
15LIFELI00077
16LIFELI00088
17LIFELI00099
18JPMCASHJP00011
19JPMCASHJP00022
20JPMCASHJP00033
21JPMCASHJP00044
22JPMCASHJP00055
23CITICASHCI00011
24CITICASHCI00022
25CITICASHCI00033
Sheet63
 
Upvote 0
Vog, any chance doing this via VBA as I will be performing this task Daily and would like to eliminate manual intervention.


Try the formulas in C2 and B2 copied down

Excel Workbook
ABC
1GroupRefNos
2NOMSNO00011
3NOMSNO00022
4NOMSNO00033
5NOMSNO00044
6NOMSNO00055
7NOMSNO00066
8NOMSNO00077
9LIFELI00011
10LIFELI00022
11LIFELI00033
12LIFELI00044
13LIFELI00055
14LIFELI00066
15LIFELI00077
16LIFELI00088
17LIFELI00099
18JPMCASHJP00011
19JPMCASHJP00022
20JPMCASHJP00033
21JPMCASHJP00044
22JPMCASHJP00055
23CITICASHCI00011
24CITICASHCI00022
25CITICASHCI00033
Sheet63
 
Upvote 0
Is there a way for the formula to avoid putting numbers in Col C as i do have data from C:W

Try the formulas in C2 and B2 copied down

Excel Workbook
ABC
1GroupRefNos
2NOMSNO00011
3NOMSNO00022
4NOMSNO00033
5NOMSNO00044
6NOMSNO00055
7NOMSNO00066
8NOMSNO00077
9LIFELI00011
10LIFELI00022
11LIFELI00033
12LIFELI00044
13LIFELI00055
14LIFELI00066
15LIFELI00077
16LIFELI00088
17LIFELI00099
18JPMCASHJP00011
19JPMCASHJP00022
20JPMCASHJP00033
21JPMCASHJP00044
22JPMCASHJP00055
23CITICASHCI00011
24CITICASHCI00022
25CITICASHCI00033
Sheet63
 
Upvote 0
Try

Code:
Sub Alisya()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B2:B" & LR)
    .Formula = "=LEFT(A2,2)&TEXT(COUNTIF(A$2:A2,A2),""0000"")"
    .Value = .Value
End With
End Sub
 
Upvote 0
Try

Code:
Sub Alisya()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B2:B" & LR)
    .Formula = "=LEFT(A2,2)&TEXT(COUNTIF(A$2:A2,A2),""0000"")"
    .Value = .Value
End With
End Sub

Vog on second thought how can we amend the code to just give 0001, 0002 etc up to the end of the data range.
 
Upvote 0
Try

Code:
Sub Alisya()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
With Range("B2:B" & LR)
    .NumberFormat = "0000"
    .Formula = "=COUNTIF(A$2:A2,A2)"
    .Value = .Value
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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