Move items categories from col "A" to col. "B"

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi to everyone, kindly require to provide me support so that a VBA code, would run through col. “A” and where find the category of the items, by which the formats are like “00000001” or 00000024, should move it in col. “B” in adjacent cell of each item. Therefore, that the spreadsheet contains more than 20000 rows and should begin from row “7”. I present below the original date and the expected result. Thank you all in advance.

Original data

1590586183905.png



Expected result


1590586201508.png
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
On a copy of your sheet, try the following:

VBA Code:
Sub categories()
  Dim a As Variant, i As Long, cat As Variant
  
  a = Range("A7:B" & Range("A" & Rows.Count).End(3).Row).Value2
  For i = 1 To UBound(a)
    If a(i, 1) Like "????????-*" Then
      cat = a(i, 1)
      a(i, 1) = ""
    Else
      a(i, 2) = cat
    End If
  Next
  Range("A7").Resize(UBound(a, 1), 2).Value = a
End Sub
 
Upvote 0
Thank you so much Dante! It works perfect and nicely. Thank you also for your time spent for my project. Hv a great lovely day!!
 
Upvote 0
I'm glad to help you. Have a nice day too. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,852
Members
449,194
Latest member
HellScout

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