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>
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,197
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
 

snuggles57

New Member
Joined
Oct 9, 2017
Messages
8
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.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,503
Office Version
365, 2010
Platform
Windows, Mobile
Re: How to write code to auto fill down using Macro

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

Forum statistics

Threads
1,082,342
Messages
5,364,783
Members
400,815
Latest member
gangstar67

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top