How to distribute/copy data from one column to others

gose

New Member
Joined
Aug 25, 2021
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hi to all.

I need to fill the columns: Name Month Week by using the data in the Grouping column.
1. Only Plate numbers must be copied to the Name column.
2. Name of the month eg July must be copied to the Month column if Name column is not empty
3. Name of the week eg Week 26 must be copied to the Week column if the Name column is not empty
4. If the Name column is empty - the whole row must be deleted.
5. In the end, the Grouping column must be deleted.

2021-08-25 (19-34-34).png

2021-08-25 (20-13-13).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
Hi,
Try this.
VBA Code:
Sub test()
    Dim mnth$, wk$, i&
    For i = 2 To Cells(Rows.Count, 1).End(3).Row
        If Cells(i, 5).Value = "" Then
            If Cells(i, 1).Value Like "Week*" Then
                wk = Cells(i, 1).Value
            Else
                mnth = Cells(i, 1).Value
            End If
        Else
            Cells(i, 2).Value = Cells(i, 1).Value
            Cells(i, 3).Value = mnth
            Cells(i, 4).Value = wk
        End If
    Next i
    Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Hi,
Try this.
VBA Code:
Sub test()
    Dim mnth$, wk$, i&
    For i = 2 To Cells(Rows.Count, 1).End(3).Row
        If Cells(i, 5).Value = "" Then
            If Cells(i, 1).Value Like "Week*" Then
                wk = Cells(i, 1).Value
            Else
                mnth = Cells(i, 1).Value
            End If
        Else
            Cells(i, 2).Value = Cells(i, 1).Value
            Cells(i, 3).Value = mnth
            Cells(i, 4).Value = wk
        End If
    Next i
    Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
It doesn't work for me. The month and week columns are not correct: 2021-08-25_20-50-50_.gif

The excel file attached: Loading Google Sheets
 
Upvote 0
Hi,
In the 5th column, there are data in the cells corresponding to the months in the columns below. The previous code gave an error because these were not empty.
Try this code once.

VBA Code:
Sub test()
    Dim mnth$, wk$, i&, mnths$
    mnths = Join(Array("", "January", "February", "March", "April", "May", "June", _
                       "July", "August", "September", "October", "November", "December", ""), ",")

    For i = 2 To Cells(Rows.Count, 1).End(3).Row
        Select Case True
            Case InStr(mnths, Cells(i, 1).Value) > 0
                mnth = Cells(i, 1).Value
            Case Cells(i, 1).Value Like "Week*"
                wk = Cells(i, 1).Value
            Case Else
                Cells(i, 2).Value = Cells(i, 1).Value
                Cells(i, 3).Value = mnth
                Cells(i, 4).Value = wk
        End Select
    Next i
    Range("B:B").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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