Macro To Do A Loop Instead Of Fill Down
Apr 10, 2012
I have a row of data. The first few columns are given data, and then the next few columns are equations that use the first few columns of data.
The next row down adds the result of a few of the equations in the row above it to the given data, and the equations are calculated again.
It looks a bit like this:
1231437-111213-9
in the first row, 1 and 2 are just given. 3 is just 1+2 (a1+b1), and in the last column, 1 is just 2-1 (b1-a1). In the second row, A2 is A1+C1, and B2 is just B1+D1, C2 and D2 are the same calcs as C1 and D2.
This row is then filled down.
What I would like to do, is just calculate what the first two columns of data are by just entering the number of cycles id like to make, instead of filling down the row.
For example, I would like to just enter N=3 in a cell, and it returns 11 and 2. Or N = 1000 and it would give me whatever the first two values are if i had filled the row down 1000 rows.
View 2 Replies
ADVERTISEMENT
Apr 25, 2014
how to fill array with cells form selections and loop my macro for each cell of that array.
Code:
'this is macro I need to execute for each cell in my selection. Here I threat each cell from selection as solo selection.
Sub SELECTION_CELL_COUNT_SINGLE()
Dim z As Integer, q As Integer, X As Boolean, I As Integer, txt As String
Dim tmp As String, J As Integer, K As Integer
Dim sStrip As String
[Code]....
View 1 Replies
View Related
May 7, 2008
i am use dir to put into an array all the folders in a folder then enter the first folder and repeat. the problem i am having is when it encounters a file it also puts it into the array and then errors once it trys to enter that "folder" (which is a file)
right now the code doesnt do anything but the plan is then to call another subroutine that lists all the files im looking for in a folder (that sub does work)
what am i doing wrong? all the things i can find on google show it the way i am doing it.
Sub GetDirList(topfolder As String)
Dim FolderArray() As Variant
Dim FolderCount As Integer
Dim FolderName As String
FolderCount = 0
FolderName = Dir(topfolder, vbDirectory)
' Loop until no more folders are found
Do While FolderName <> ""
If Not FolderName = "." Then
If Not FolderName = ".." Then
FolderCount = FolderCount + 1
Redim Preserve FolderArray(1 To FolderCount)
FolderArray(FolderCount) = FolderName
End If
End If
View 3 Replies
View Related
Aug 3, 2014
I'm looking to create a macro, one where depending on which the active cell is, if I hit say Ctrl + Shift + D. The macro would fill down the row I selected one row, but there are certain columns I want it to fill down: I want it to Fill Down columns: A to E, G, I, K, M to P, R to T.
For example, my cursor is in cell N45, I want it to fill down row 45, but only columns A to E, G, I, K, M to P, R to T to row 45.
Can this be done. My testworkbook is attached.
View 9 Replies
View Related
Dec 9, 2008
I have enclosed XLS sheet where you can see line [in highlighted] that a blank. I need a macro to search for such blank cells and fill it with the data on top of it, example A5 = 4, B5= blue, A12= 1 and B12=golden.
View 7 Replies
View Related
Nov 29, 2011
I need a macro to perform the following:
On column A, from row 2 to 22, I have on each cell, an equal to (=) formula which links the result from another sheet in the same work book.
I need a macro that begining on Column C, everytime the cells in Column A changes from 0 to a number, displays the number on column C and when cell in Column A goes back to 0, Column C retains the number. Next time Column A displays a new number, then Column D is filled, next number Column E and so on.
Example: Lets suppose that cell A2 shows 1234, then cell c2 will show 1234, once cell A2 goes back to 0, cell C2 remains 1234. Then when cell A2 shows a new number 5678, then cell D2 will display the new number 5678 and if A2 goes back to 0 cell D2 will retain the number 5678 and again, once cell A2 displays a new number 1589, then E2 will display 1589, etc, etc. This could happen as many as 20 times (up to column V) before erasing all columns and beginning all over again.
View 8 Replies
View Related
Jun 3, 2014
my macro filling down the data properly. I have a table wit headers set up. My macro selects two cells in the first row, and tries to copy it down into the other rows of the table. Instead what happens, the macro copies down the table headers into the two cells that are selected. Here is my code.
Range("I3").Select
ActiveCell.FormulaR1C1 = "Order Filled"
Range("J3").Select
ActiveCell.FormulaR1C1 = "Order FIlled"
Range("I3:J3").Select
Selection.FillDown
View 3 Replies
View Related
Jan 8, 2009
I am looking for a Macro to fill in a formula in each row where there is a value. So if there is a value in row 1 Column A then place this formula into Column B and continue down the sheet untill there is not a value in Column A.
View 9 Replies
View Related
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
Jul 1, 2006
I've recorded a macro where I have selected two adjoining cells in Row-9. I double-clicked at the cells to fill-down the formulas to the end of the range. However, the macro recorded: Selection.AutoFill Destination:=Range("H9:I152")
Of course, I will be adding and deleting rows from this worksheet. The next time I run the macro my range may only be to row 80 or it may be up to 200. How can I make the macro dynamic, so the AutoFill goes from H9 to "the end of the range"?
View 2 Replies
View Related
Apr 14, 2007
I need a macro that is able to fill down data in a selection. For example, in “A5” I have “BB Total” in “A8” I have “CV Total” and in “A13” I have “GH Total”. I need a macro that will take A5 and fill it down to A7, then take A8 and fill it down to A12, then take A13 and fill it down to the next one, and so on. I attached an example. Sheet one is unfinished and Sheet two is finished. I want to be able to select the data the macro runs on. I highlighted in Yellow what I would like to be able to select before I run the macro.
View 3 Replies
View Related
May 6, 2014
I'm using 3 sheets within one Excel file. 1st sheet (target) is called Offer, the 2nd one (source) is called Stock and there's a 3rd one that only contains a button to which i'll assign the final macro. Now, back to it.
I need to copy from Stock to Offer contents of the entire column (basically there are a few more in Offer, so i need to copy each one and place it in a different part). I need to copy from ROW 2 and paste in ROW 6. The length of the document varies, as it's connected to the database (now i can have 3800 rows, in the next hour 3765). Previously i just added an X to row 4500 ( i don't expect to EVER have more than 4000 lines) and just copied from 2 to 4499
Second issue is, on the Offer sheet i have to fill a column with a certain value. Again, it needs to start from Row 6, and needs to be as long as the adjacent column. To get a better idea, i have for example 3800 price lines, so i need the column next to it to be filled with 3800 rows saying GBP (this will be a fixed value).
Also, none of the codes above should exclude blank cells in the middle of the string. Last thing, seems some of the barcodes i have only have 12 digits, so i'll need to add a 0 in front of all shorter numbers to go up to 13 digits.
[Code] ......
I should be able to figure the rest by recording bits and pieces. The Save part is done already, i'm using
[Code] ....
I needed it in XLSX format, not XLSM so that suits just fine. I might need to add hour and minute as well but i can sort it out (as i said, i can do some stuff on my own but this one got me to the bottom).
View 2 Replies
View Related
May 21, 2014
I need a macro that will insert this formula: =Trim(IF(B3="","",MID(B3&", "&B3,FIND(" ",B3)+1,LEN(B3)+1))) into column C starting on row three through the end of the spreadsheet information.
I typed this incorrectly when I first posted. I need it to fill down into only column C not the end of the spreadsheet.
View 14 Replies
View Related
Apr 27, 2009
What I need , is a macro to take data entered from "worksheet1" and fill in next row on a separate worksheet based upon salesman selected from cell C20 in "worksheet1" .
For the sample, I have just 3 saleman in a dropdown list and have labeled worksheets accordingly. If i could get help with say just using info from cells C6,c7 and e6 from "worksheet1" and put it where it goes.
c6 last name is row b on data sheet
c7 first name is row c
e6 trade year is row o
I should be able to work out the rest.
View 4 Replies
View Related
May 17, 2013
I am having some issues with my macro. I keep getting a syntax error? I am trying to combine these coding combinations together. Code G0398 with 95800, code G0398 with 95801 so on so fourth..
G0398
95800
G0399
95801
G0400
95805
[Code] ...........
View 2 Replies
View Related
Jul 25, 2007
Col D has list of order #'s, starting in row 9. Col M is for COMMENTS about each order. Order #'s can appear in Col D more than once.
What I am looking for is a macro that will automatically detect if I have entered a new COMMENT in Col M, recognise the order # in adjacent Col D, and put my new comment in other cells in Col M if the SAME ORDER # is referenced in adjacent Col D.
Example:
worksheet starts with:
Col D Col M
1234 x
123 xyz
1234 zyx
4321 zyx
321 y
1234 yz
If I type the letter "Q" into Col M in a row adjacent to order # 1234, the result should be:
Col D Col M
1234 Q
123 xyz
1234 Q
4321 zyx
321 y
1234 Q
I think I would need to put this macro into a Worksheet Change event but beyond that I do not know what I need. UDF? Macro?
View 9 Replies
View Related
Jan 16, 2009
I have been helping a friend keep track of his clients, by making a form for them to fill out when they become a client of his (he owns a care rental) and I made a spread sheet for him to keep track of which cars are out when...
With that said, I would really like to have a Macro that i could run, when the form with all the personal information about hte client had been filled out - take that information and pull it over into another spead sheet that keeps track of all clients.
Meaning that workbook 1 is set up as a booking form and workbook two is just a normal list. I can make a macro that pulls over the infomation - but the problem is that it will always pull the information into row 1. Meaning that it overwrites itself each time I run it. I would like the Macro to know that it has to fill the information into the next empty row.
View 9 Replies
View Related
Jun 6, 2006
Let's say I have data from column A up to column J.
Columns M, N, O contain formulas which calculate value from column J. Since this sheet is a template, the number of rows of data vary from month to month, i.e. the amount of records I copy and paste to columns A-J vary.
I would like to have a macro which will fill down the formulas in columns M, N and O as many as there is data in column J. Example: Let's say minimum number of row is 100, so up to row 100, column J already contains formulas. But if the following month the number of rows is 150, I would like the macro to automatically fill down the formulas in columns M, N and O up to row 150. But if the following month, there is only 130 rows, the macro should fill down to row 130 only.
View 4 Replies
View Related
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
Nov 29, 2006
I wonder if soeone could change the following macro so that the bottomcell
is set to be as far down as there is content in Column "A". As it stands if I fill in blank cells in Column "C" and the last cell with data is say C10 it does just this. But if the actual last row with data in column "A" is A14 then cells C11, C12, C13, and C14 are ignored. C11, C12, C13, and C14 should be the same as C10 above them.
Sub FillBlankCells()
Dim topcell As Range, bottomcell As Range
Set topcell = Cells(1, ActiveCell.Column)
Set bottomcell = Cells(16384, ActiveCell.Column)
If IsEmpty(topcell) Then Set topcell = topcell.End(xlDown)
If IsEmpty(bottomcell) Then Set bottomcell = bottomcell.End(xlUp).Offset
Range(topcell, bottomcell).Select
Selection.SpecialCells(xlBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
End Sub
Other macros recognize the actual last row.... but have issues with columns formatted as Text. The macro above doesn't create problems with columns formatted as "Text".
View 3 Replies
View Related
Jun 12, 2008
I have written a macro that creates a new spreadsheet and copies text into it. The number of rows varies depending on the input.
Yet, running the macro results in a sheet with the max rows (65k+). This is unmangeable, as it makes it a huge file and size and harder to print.
I only want there to be the number of rows that have text in them.
The larger problem is how these were even created in the first place. Currently:
' Formula for Job Name
Range("A2").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[12],8)"
' Fill Job Name
Range("A2").Select
Selection.AutoFill Destination:=Range("A2", Cells(Rows.Count, "A")), Type:=xlFillDefault
View 3 Replies
View Related
Apr 15, 2009
I found this script which is very similar to what I want to do but I am not sure how to finish modifying it.
This script compares every cell in Column B to Z on Sheet1 with Cell A1 on Sheet2, if it matches it will copy the active cell in column A and past the results to column A no Sheet3.
View 10 Replies
View Related
May 12, 2012
I am the consolidator for a specfic Excel file to be converted into CSV. In order for this file to be uploaded into our database properly it needs to be in a specific format and certain values must be entered if other cells have been filled in. At this point I have locked the formating so users cannot change it and I have created a Macro for blank cell rules.
The Macro is to verify that cells are not blank if the value in A is not blank. At this point it works as it should, for row 4. However, I would like to Loop this Macro throughout the entire worksheet.
The Macro I have created is (minus several columns for simpler reading purposes):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Worksheets("JE FILE").Range("B4").Value = "" And Worksheets("JE FILE").Range("A4").Value "" Then
MsgBox "You must fill in Customer."
Cancel = True
[Code] .......
How do I LOOP the Macro?
View 3 Replies
View Related
Feb 28, 2008
Currently, I have two spreadsheets.
The first (SS1) is where my raw data is populated.
The second (SS2) is my template.
In the first spreadsheet, I have a macro (button) that opens up SS2.
Then in SS1, I also have another button that I click and it 'transfers' the first line of data to SS2.
In SS2, I have a save Macro, which basically saves as per the name in Cell A1.
What I would like to do is to loop the process, i.e. when I click the 'Transfer' button in SS1, it will open up the 'template' spreadsheet (SS2), copy the information across, save & close and repeat this for the remaining data in SS1.
Is there a simple coding to use that can loop this process for me?
I would attach the two spreadsheets for you to view but I am unsure how to upload on here.
View 9 Replies
View Related
Dec 10, 2008
I would like the macro to loop through rows and highlight the cell in column G if the value is at least 2x greater than the value in the cell in column D.
Right now I have a very long macro... but I'd like to change it so goes through all the rows I assign it to instead of writing many lines of code (lots of if then statements):
Sub Macro4()
Range("G28").Select
If Range("G28") > 2 * Range("D28") Then
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
View 9 Replies
View Related
Apr 30, 2009
if i am in an active cell which is empty and want to stop the macro at this point, what code should i type in visual basic to achieve this
View 9 Replies
View Related
Aug 4, 2009
I'm trying to get this macro to loop and have no idea what I need to do do to get the macro to keep repeating until it gets to the last item in a list.
I have a list of addresses (some are 3 rows long, some 4 and some 5). And I want to Copy each one then paste special in the empty cell between it & the next address entry.
Here's the code for my simple macro that does one copy & paste ... I have to do each one manually & would like to modify the macro to go all the way to the end of my list.
I read that there are 4 types of loops (While Loop, For Loop, Do While, ??) ... don't know how to choose which one or how to use/format with my exisiting macro.
Sub Transpose_j()
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
End Sub..........................
View 9 Replies
View Related
Jun 17, 2006
I have record a macro to sort the data on one .csv file .
I have about 1000 of this similiar .csv files, I would like to have a macro loop to repeat the sorting and arrangement .
Workbooks.Open Filename:= _
"G:Data20060616.csv"
Cells.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
View 3 Replies
View Related
Sep 17, 2013
I am trying to create a macro that will automatically fill in the days for a user if they fix the date. That is my end-goal, but obviously I have to take it step by step.
My first complication is how can I fill in all of the day rectangle boxes automatically? I was trying to create a macro for it, but it would only change the very first box. (You can see from my sheet, the days go 3 then 2)
After that I want to try and have constant-macro where if they change the month and the year it will automatically update the calendar for the user.
View 5 Replies
View Related
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