Add Formula & Auto Fill Via Macro Code

Mar 13, 2008

I want a Macro to be able to copy a formula down from cell A2 down the entire column within the data range. But, the problem I've got is that the spreadsheets I'll be using the Macro on will be different sizes. Currently, the VBA looks like this:

ActiveCell.FormulaR1C1 = "= LOWER(RC[3])"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:A17340"), Type:=xlFillDefault
Range("A2").Select

So the "Destination:=Range("A2:A17340")" part copies the formula into all cells from A2 to A17340. Other spreadsheets might only have data up to cell A200, or Awhatever - is there a way of getting the macro to populate just the cells in column A but only where there is data adjacent in other columns?

Also, I want the Macro to be able to delete all rows wherever "DELETE" appears in a certain column - I had a look at the "Delete Entire Row Based on Criteria" Macro but I'm looking for a fully automated solution, rather than the question boxes coming up and asking which cell/criteria, I need to run this macro on multiple sheets and the criteria/column position will always be the same -

View 7 Replies


ADVERTISEMENT

Create Macro Code That Auto Fill Cell With Formula?

May 23, 2014

When I enter data in the cells A1 and B1, C1 needs to calculate the result. (not copy and paste)

For examle: I have formula C1=(A1+B1)/2

C column for formula, but shows result only when there is a data in A and B

View 7 Replies View Related

VBA Code To Auto Fill Formula Generates Error

Nov 17, 2012

Why this error is coming up on a macro. Now to what I'm trying to accomplish is I have 1 sheet called GDL and I want to pull certain data from that sheet into another sheet called data sheet. I have formulas set in the data sheet to pull the information I want. However, I want to create a macro to pull the data for those formula or I guess another way of looking at it would be a auto fill function, except with a macro button. Please see the following error I receive when trying to run the macro.

Run-time error '1004': Autofill method of range class failed. The following is the macro.

VB:
Sub ResetDataSheet()
'
' ResetDataSheet Macro
' Macro recorded 11/13/2012 by asdf
'
[Code] ....

View 5 Replies View Related

Copy/Fill Down Formula Macro Code

Jun 5, 2008

I have created a macro with the below formula in it:

Range("L2").Select
ActiveCell.FormulaR1C1 = "=LEN(RC[-1])"
Range("L2").Select
Selection.AutoFill Destination:=Range("L2:L234")
Range("L2:L234").Select

I am using column K and it looks up the length of this cell. When I created the formula I was using info that only went to line 234 which was fine. Once I clear the info in column K and input new info it can go further than line 234. How do I get the macro to look up the whole of column k without having to create a new macro each time?

View 6 Replies View Related

Auto Fill Off Of Zip Code Entry

May 19, 2009

If I have 3 fields: zip code, city and state; is there a way where I can have the user of my form enter their zip code and it will populate both city and state. I have the data, I just dont know exactly how to code it.

View 9 Replies View Related

Auto Fill Dropdown Not Showing When Typing Code?

Oct 8, 2012

I am not sure the correct term for this but the autofill drop-down menu that pops up when typing code does not come up for me.

Example:

Sheets("Form").combobox1.

I usually get a drop-down menu with a list of members of the "ComboBox" class.

Is there a setting for that enables/disables this?

View 7 Replies View Related

Enter Only Part Of A Zip Code And Have The Rest Auto Fill-in

Mar 3, 2009

i have an excel sheet where i enter company information including Zip code. the zip codes around here all start with 797 and end with numbers from 01 to 12

i am looking for a way to enter just the last 2 numbers and have it automatically insert the full zip

example:

line one i would enter 01 and 79701 would show up in the box.

I know there are ways to do this, just can't remember its been so long since I've had to use excel.

View 9 Replies View Related

Auto Fill Formula Using $

Jan 24, 2008

I created a database and made one small mistake doing it. The database is infinite amount of rows down and my formula needs to be corrected as such. In the current cells: (C1:C1000) i have the formulas referencing cells $B1, but i need it to reference $B$1. In C2 I need it to reference $B$2, C3 $B$3 and so on. If I autofill, it obviously just keeps the following cells at $B$1 and i can't keep the dollar bill sign.

View 9 Replies View Related

Excel Auto Fill Formula?

Jun 14, 2013

I have an excel spreadsheet like the one attached. My problem is column A has a ton of blank cells. Wht I'm trying to do in Column A is write a formula that fills in the blank cells with the number of the last previous filled in cell. For example the first number is .25 I want to fill in the blank spaces below it with .25 all the way until it reaches a different number which in this case is .219.

Once it reaches .219 I want it then to fill in the blank spaces below it with .219 until it reaches a different number. So basically I'm looking for a formula to fill this in on its own instead of having to drag the cells over and over again manually.

In the excel spreadsheet attached I have in Column D the end result I wish to accomplish.

example.xlsx

View 5 Replies View Related

What IF Auto Fill Date Formula

Nov 1, 2007

I would like to auto fill the present date if another cell of the same row is typed in and then lock that cell with the date.

For example. If someone types in cell A2 then I would like to auto fill D2 with the date 11/01/2007 and lock it.

If someone tomorrow types in cell A3 then the date would once again be autofilled in D3 to 11/02/2007 while D2 would still display 11/01/2007.

View 9 Replies View Related

Auto Fill Within Macro

Sep 14, 2009

my macro simply activates a cell and all i want it to do is to auto fill downwards!
its intended to autofill down for about 100 rows but just cant figure it out!

but keep in mind the cell is always going to change so it cant be fixed

i.e this wont work:

Selection.AutoFill Destination:=Range("C95:C659")
Range("C95:C659").Select
ActiveWindow.SmallScroll Down:=513

because i need it to be autofilled from the CURRENT active cell only!

View 9 Replies View Related

Auto Fill Formula Along Length Of Report

Feb 6, 2009

I'm trying to use the coding below to insert a formula down the lenght of the report but it is coming up with a run time error.

View 2 Replies View Related

Auto Fill Multiple Worksheets In Formula Bar?

Jul 4, 2012

I have a workbook that has a "summary sheet" and then forty some sheets thereafter. Each row on the summary sheet represents a sheet in the workbook. For instance, i.e. on the worksheet tabs below it is displayed left to right as follows: "summary page"(sheet1), "aaa"(sheet2), "bbb"(sheet3), "ccc"(sheet4) etc. On the summary page, row one identifies the aggregate of sheets in a horizontal fashion, i.e. cell A1: "aaa"; cell A2: "bbb" and cell A3: "ccc" etc. I am pulling data for various parameters as columns on the summary page relative to each row (representing each sheet) via "SUMPRODUCT" and "COUNTIF" formulas. The formulas are a constant as each sheet's rows and columns are identical, the only variable in a given formula is the sheet name.

For example: =COUNTIF('aaa'!$C$4:$C$16,"Online")

This works fine if I drag and auto fill the column on the summary sheet, except for the fact that I have to manually type in: 'bbb' in the formula for the next row down in said respective column (COUNTIF('bbb'!$C$4:$C$16,"Online") and 'ccc' (COUNTIF('ccc'!$C$4:$C$16,"Online")and so forth forty some times thereafter.

Given that I am encountering this issue over multiple columns, I am easily going to have to manually alter some 300-400 cells at this rate should I not find a solution. I know there must be an easier way, I have tried creating a 'Custom Autofill List' but this does not translate to the formula bar and thusly will not fill the series. Additionally, I have tried to create a Macro but my lack of knowledge in VB and overall in this area of Excel has proved to be a difficult task..

View 3 Replies View Related

Auto Fill Down Formula From Active Cell

Mar 11, 2013

I am desperately find a way to fill down formula from active cell, example given below,

AA
BB
CC
Total
QTY1
QTY2

City 1
5
2
3
10
12
15

[Code] .......

I need to fill down col Qty 1 & Qty 2. Number of Rows and Columns vary in my Work Sheet.

My code below, Ctrl+Enter not works.

HTML Code:
Cells.Find(What:="QTY1").Activate
ActiveCell.Offset(1, 0).Select

ActiveCell.FormulaR1C1 = "=RC[-1]+RC[-3]"
'Fill Down Active Column

Cells.Find(What:="QTY2").ActivateActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=+RC[-5]*RC[-3]"
'Fill Down Active Column

End Sub

View 3 Replies View Related

Auto-Fill Formula When Adjacent Cell Changes

Jan 6, 2007

what is prompting this formula to auto fill down when a value in an adjacent cell is entered.

In column A I enter an unformatted fax number.
In column B I use the following Text Formula:
"="("&LEFT(A20,3)&")"&MID(A20,4,3)&"-"&RIGHT(A20,4)

Someone in my office copied the workbook and now any time a value is
entered into the next available Column A cell. The cell in column B will automatically apply the above formula and format the fax number. The person who copied the workbook does not know how this is working nor does anyone else in the office.

There are no macros embedded in this workbook so no event is firing to cause this.

I have attached a small copy of the workbook called "Auto format1.xls"

How to use:
-Select cell B20 and not nothing is in it.
-Enter any 9 digits in A20 and B20 somehow
copies down the formula from B19.

how to duplicate this.

View 9 Replies View Related

Macro To Auto Fill Dates In Column

Jan 14, 2009

I have a startdate F1 and an end date G1. Is there a macro that can list all dates by day within that range into column I7:down.

View 9 Replies View Related

Auto Fill Value In Different Cells In A Row Using Macro Button

Jul 30, 2012

how to auto fill of same value in different cells in a row?

For Example:

A1 D1 E1 G1 K1
10 10 10 10 10

like that when i hit a macro button the values in the A1 D1 E1 G1 K1 must fill with A2 D2 E2 G2 K2

View 1 Replies View Related

Auto Fill Macro For Fields Below Active Field

Apr 9, 2014

I need a simple macro to use for conditional autofill of cells below the active cell (to the end of the sheet) with the text that is being entered in the active cell.

DESCRIPTION: I have two columns of data, the first (call it Col1), has a word number which is unique to each specific word in a foreign language, every cell in this column has a number in it from 1 to 30000. Each number reoccurs many times in cells over the length of this column.

The other column (call it Col2) is blank. As I type words in english in each cell of this column, I need the macro to autofill the text that I have just entered, into every cell in Col2 where it's Col1 number is a match with the Col1 number where I am typing.

For example, in one row, Col1 has the number "21" and I type in Col2 the word "run". I need the macro to find every row where the number 21 is found in Col1 and automatically enter "run" into Col2 at that location.

The macro must only autofill cells which have no data in them. Preferably from that cell down, although if that is not possible, all cells would work seeing we are only replacing blank cells with data.

View 5 Replies View Related

VBA Macro Needed For Auto Fill Using Another Cell Reference

Apr 28, 2009

Is there anyone who can suggest a solution to my problem below ?
Basically, what I need is a macro which would ideally work like this:

if D32 = 1, then the background colour of D4 should be red
if D32 = 2, then the background colour of D4 should be orange
if D32 = 3, then the background colour of D4 should be yellow
if D32 = 4, then the background colour of D4 should be green

And then I plan to use it for columns E, F, G

View 9 Replies View Related

VBA Macro To Delete Rows/Columns, Insert Formulas & Auto Fill

May 28, 2009

I'm running a macro that opens another workbook and read data from it.How can I incorporate this code into my macro.Sorry i don't knwo VBA.

Workbooks.Open Filename:="C:Documents and SettingsmsimantbDesktopINFRACHEM_POLYMERS - DON''T DELETE.xls]Sheet1"

UserGRP_MAcro Macro
Rows("1:3").Select
Selection.Delete Shift:=xlUp
Columns("A:B").Select
Selection.Delete Shift:=xlToLeft
Columns("B:E").Select
Selection.Delete Shift:=xlToLeft
Columns("A:A").EntireColumn.AutoFit
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("B1").Select
ActiveCell.FormulaR1C1 = "Existing userGroup"............................

View 2 Replies View Related

Fill TextBox Macro Code

Oct 11, 2006

i have a userform named: usf_History.

i would like to refresh all the text boxes (they either refer to cells or are calculations)...?

View 6 Replies View Related

Fill Range From IBM Reflection Macro Code

Apr 29, 2008

I'm working on some macros to fill and file paperwork from an IBM Reflection based system into an Excel spreadsheet. Here's the code I've written so far:

Private Sub cmdSend_Click()
Dim ExcelObj As Object
Dim ExcelWasNotRunning As Boolean
On Error Resume Next
Set ExcelObj = GetObject(, "Excel.Application")
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear
DetectExcel
If optObligation = True Then
Set ExcelObj = GetObject("S:PublicVisual Basic FormsExcel FormsObligation.xls")
Else..............

The problem I'm running into is that the data isn't loading the first time through. The spreadsheet opens, nothing happens, Excel closes. If I attempt to run the macro again without closing the form and clearing all the variables it runs perfectly as many times as I want to run it (which isn't terribly useful, because I'm stuck putting the same data into the form over and over again). If I unload the form then I get the same problem: first run, no data transfered.

View 6 Replies View Related

Auto Fill After Inserting Row Without Using Fill Handle?

Apr 30, 2014

Is there anyway to automatically fill the empty added cell after inserting a row without using the fill handle? For example, for a series of numbers: [URL]

2. Drag the fill handle Selected cell with fill handle across the range that you want to fill.

Or running balance: [URL]

2. Extend the running balance formula into the new rows by selecting the last cell in the balance column and then double-clicking the fill handle.

View 6 Replies View Related

VBA Code To Automatically Fill Down And Apply Formula Till Last Cell

Aug 22, 2012

I am using this code and it works fine:

Dim MyData As Range
Dim MyResult As Range
Set MyData = Range("E1:E1000000")
Set MyData2 = Range("F1:F1000000")
Set MyResult = Range("J4")
MyResult.Select
Selection.Formula = "=COUNTIFS(" & MyData.Address & ",""=Kim""," & MyData2.Address & ",""=done"" )"

Is there any way I can change the code so that it automatically finds the last cell as Im using Range("E1:E1000000") and Range("F1:F1000000") because there will not be more than 1000000 entries.

View 2 Replies View Related

Macro Code To Find / Insert And Fill Text?

Oct 11, 2011

I need a macro script that goes to a particular cell in a column based on a criteria (say, locate the first instance where $0.21 appears in col. H), insert a row above it, and fill the row with the text "Note:These are above $0.20"

View 2 Replies View Related

Auto Enable Macro Code

Feb 23, 2009

what the code to auto enable a macro? I have tasks running on my computer. Everytime they run, I have to click on enable macro. I thought there was a way to automate this, but I can't find the code......

View 9 Replies View Related

Auto Sort Macro Code

Apr 22, 2008

I have a spreadsheet to create with columns A-I, this will be used by others when I am away and the problem is I dont want them to have to keep going into the data-sort option. Is there a way that I can get the items to auto sort into alphetical and numerical order across the columns? Personally I would be happy with sorting the columns manually each time it's accessed but I know the others using the program won't be!! How would it work if its poss? would it auto sort on saving?

View 3 Replies View Related

Auto Fill Formula Every Nth Cell And Lookup Value Every Nth Cell In Source?

Dec 19, 2013

Source tab contains vital information about some clients.

In the aggregated tab (Cell C10) I created a formula that pulls the Inflows from the source in a very specific array. So for client 1, this works fine. Now, if i copy my formula to the client 2 (Cell C14), it obviously wont go and look in the correct array in my source.

What i need to do is to be able to copy/paste my formula

[Code].....

(from cells C10 to CC10) to cells C14 to CC14, but when copied, the look up array changes to:

Formula: [Code] ....

I will have to fill this formula to at least 100 entries down, so i need to make it work with ease

The good thing is that all look up values in the source increase by a fixed number of rows (12). I tried playing with index/rows formula.. no luck..

Attached File : samplev1.xlsx‎

View 1 Replies View Related

Code To Auto Populate A Relative Formula Into A Column

Mar 13, 2009

I have a report that I run off a database and extract to Excel.

It has 3 fields: Title; FirstName; LastName. For example sake lets say they are in columns A, B, C. Now in D I have a fieldname of FullName and in D2 onwards the formula: =A2&" "&B2&" "&C2.

Now I currently manually type the formula and drag it down to the same row as the last entry in the first 3 columns so that I get the full title in one cell.

I wanted to know how I could enter the the formula above in column D so that it automatically does this for me?

I tried to record a Macro as a test for column D setting the field name in D1 and the formula in D2 and got the following:

View 2 Replies View Related

Error In Macro When Auto-pasting Code

Jun 4, 2014

I'm new to VBA but have had it working well for me, until the other night when a user complained that when he ran a macro, it came up with the error "Paste method of Worksheet class failed". I should note that this has worked time and time again, so I'm lost. I also found tonnes of answers with a Google search but they were all relative to that persons code.

So this is the code I am using to paste from the clipboard into another tabbed worksheet :

[Code] .....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved