Code to auto fill down using Macro

hbuehanx

New Member
Joined
Oct 6, 2017
Messages
2
I extracted data from another database. I want to make this data in pivot table formatting, which means fill Country and Product Column in every row so I can do analytics by country or by product type. There are 15000 rows. How can I do it using Macro?

BCD
CountryProductProduct Type
QATARGeneratorsType 1
Type 2
Type 3
LeadsType 1
Type 2
Type 3
Type 4
OtherType 1
Type 2
Type 3
BRAZILGeneratorsType 1
Type 2
LeadsType 1
Type 2
Other Type 1
Type 2
Type 3
Type 3

<tbody>
</tbody>
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Re: How to write code to auto fill down using Macro

Based on how you depicted your worksheet design, try this:

Code:
Sub Test1()
Application.screenupdating = False
Dim LastRow As Long
LastRow = Cells(Rows.Count, 4).End(xlUp).Row
On Error Resume Next
With Range(Cells(2, 2), Cells(LastRow, 3))
.SpecialCells(4).FormulaR1C1 = "=R[-1]C"
.Value = .Value
End With
Err.Clear
Application.screenupdating = True
End Sub
 
Upvote 0
Re: How to write code to auto fill down using Macro

I am hoping some one can help me I am looking for some code to FillDown a selection of non consecutive cells. I recorded a basic macro below.

This is only a small sample of number of rows that I need to fill down.
Range("A22:D25").Select
Selection.FillDown
The next range skips 2 rows then continues to the next range
Range("A28:D31").Select
Selection.FillDown
This needs to continue in the pattern until the final range or stop if any of the copy down cells is blank. Final range would be.
Range("A3436:D3439").Select
Selection.FillDown

<colgroup><col></colgroup><tbody>
</tbody>



The column to the left of the cells mention in the macros have detail of hours worked start time etc when filtering on any of the other columns the persons name does not appear. Thats why I need to fill down spanning the four rows.

Many thanks for any help given.
 
Upvote 0
Re: How to write code to auto fill down using Macro

Deleted as didn't realise someone had hijacked the thread.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

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