macro auto fill for each part

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
245
Office Version
  1. 2019
  2. 2010
I would repeat autofilling the item in column A for each part locate before TOTAL row . some parts contian one item , so no need repeat the item .
I would do that by macro please.
before
ITEM.xlsm
ABCD
1DEL NOBATCH NO TTLTT1
2CCCC-1SS-1TRU
3CC-1SS-1LTR
4CC-2SS-2FG
5TOTAL
6CCNCC-1SS-1TRR
7CC-1SS-1LTR
8TOTAL
9CDCS-1LL-1RRL
10CS-2LL-2TTY
11CS-3LL-3MMW
12CS-4LL-4NNW
13TOTAL
14CCLCC-2SS-2LTR
15TOTAL
16CCMCC-3SS-3LTR
17TOTAL
data


after
ITEM.xlsm
ABCD
1DEL NOBATCH NO TTLTT1
2CCCC-1SS-1TRU
3CCCC-1SS-1LTR
4CCCC-2SS-2FG
5TOTAL
6CCNCC-1SS-1TRR
7CCNCC-1SS-1LTR
8TOTAL
9CDCS-1LL-1RRL
10CDCS-2LL-2TTY
11CDCS-3LL-3MMW
12CDCS-4LL-4NNW
13TOTAL
14CCLCC-2SS-2LTR
15TOTAL
16CCMCC-3SS-3LTR
17TOTAL
data
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
According to your attachment a VBA demonstration for starters :​
VBA Code:
Sub Demo1()
        Dim Ra As Range
    With Sheets("Data").UsedRange.Columns(1)
        If Application.CountBlank(.Cells) = 0 Then Exit Sub
        Application.ScreenUpdating = False
        For Each Ra In .SpecialCells(4).Areas:  Ra(0).Copy Ra:  Next
    End With
        Application.ScreenUpdating = True
End Sub
 
Upvote 0
You could try this with a copy of your data.

VBA Code:
Sub FillBlanks()
  With Range("A1", Range("A" & Rows.Count).End(xlUp))
    .SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
  End With
End Sub
 
Upvote 0
The issue using a formula is the cell formatting is not copied if this is not within an Excel table …​
 
Upvote 0
The issue using a formula is the cell formatting is not copied if this is not within an Excel table …​
Yes, I am aware of that. The op can decide if that is relevant/important.
 
Upvote 0
the codes are perfect. just question , how can I implement your codes for multiple sheets with the same structure,please?
 
Upvote 0
Why the important information is not in the initial post ?‼​
If all the worksheets have the same structure my VBA demonstration revamped :​
VBA Code:
Sub Demo1r()
         Dim Ws As Worksheet, Ra As Range
    For Each Ws In Worksheets
        With Ws.UsedRange.Columns(1)
            If Application.CountBlank(.Cells) Then For Each Ra In .SpecialCells(4).Areas:  Ra(0).Copy Ra:  Next
        End With
    Next
End Sub
 
Upvote 0
Solution
Why the important information is not in the initial post ?‼
my apologies ! you're right . actually current case just I have one sheet , but I tought maybe I have many sheets in the future so I don't want come back to mod your code . that's it .
thanks very much for your time
 
Upvote 0

Forum statistics

Threads
1,215,706
Messages
6,126,332
Members
449,308
Latest member
Ronaldj

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