I have cobbled together some code that I hoped would do the following:
Sort data Copy all data from one person and put it on a sheet Create a pivot on that data populate another sheet based on that persons data Save as a PDF Clear the data and start again for the next employee
I have copied this from other macros I have used in the past. Up until now the parts I have been working on have been ok. however when I try and run it now I get a "Loop Without Do" error. I really can't figure out why.
I'm trying to do a for each loop in a row, I've tried to drill it down to be as simple as possible, but I keep getting the Run-time error '424': Object Required
I've tried to make it simple, with just inserting a 1 into the cells, still get the error.
Code: Dim firstRow As Range Dim rCell As Range Set firsRow = Worksheets("MAIN").Range("F3", "AG3") For Each rCell In firstRow 'error shows here rCell.Value = 1 Next rCell
I need my macros to search for the word "Cancel" in columns "T". Once found, I need the macros to make that entire row a certain pattern ( .Pattern = xlGray16)
There will be other wording in these cells that contain "Cancel" or "Cancelled".
A compile error keeps occurring. It says "Ambiguous name detected: FormatCell"..
Sub DoCancelCells()
Dim strSearchString As String Dim wksSheet As Worksheet Dim rngSearchRange As Range Dim intSearchCount As Integer
I've got the following code which opens/gets the excel files from a specified directory and imports them into an open workbook. I've added a GoTo Error before my loop which checks if there are any files in the directory and shows an error message if it's the case. Problem is since the loop goes on till there are no more files in the directory, it goes back to the error. How to change that ?
VBA but familiar with other programming languages.
I have looked through previous posts with the same problem and I see that most people forget to add the "endIf" before looping. From what I can tell, I have ended all of my "If" statements.
The goal of this macro is to take temporary data and finding a match in other sheets and copying from "Temp" and pasting into the other sheets (possibly in the first blank cell, depending on the case) then deleting the row and moving on to the next row and repeating the process until "Temp" is empty.
I am getting the Run-time error '380'. Could not set the value propery. Invalid property value.
I have a user form for data entry purpose which is working fine. Now, I am making a code for data editing purpose which pulls out data from the worksheet into the user form.
I am able to do this for text boxes and combo boxes that are not linked with each other. However I am getting a problem in the following case; I have a combo box and a text box that are linked to each other by combo box _change code which is below which may be the reason for the error I am getting for the next code...
Code: Private Sub cmbColor_Change() If cmbColor.Value = "Other" Then lblColor.Visible = True
My current code opens a file ("Report01.CSV") from the directories in column A (one at a time), and copies data into sheet 2.
The problem is that sometimes there is no ("Report01.CSV") file in one or more of the directories.
What I would like to add is an error handler that would remove the directory (delete that cell) that caused the error and continue with the loop. I.e. resume importing data from the other directories.
CODE: Dim wrkMyWorkBook As Workbook Dim lngRow As Long: lngRow = 1 Dim lngColumn As Long: lngColumn = 2
Do Until Sheets("Sheet1").Range("A" & lngRow).Value = vbNullString Set wrkMyWorkBook = Workbooks.Open(Filename:=Sheets("Sheet1").Range("A" & lngRow).Value & "" & "REPORT01.CSV") lngRow = lngRow + 1
I'm trying to create a simply loop for an easy task of copying and then pasting a formula into other cells. Basically I'm trying to get this script to run until there is no more "slsperson" references to go to.
Sub z_Paste_Sales_Formula() Dim i As Long Dim icolumn As Integer icolumn = 4 Cells(3, icolumn).Select Selection.Copy i = 1 Do Application.Goto Reference:="slsperson" & i ActiveCell.Offset(1, 0).Select sls_row = ActiveCell.Row ActiveCell.Offset(1, 0).Select gp_row = ActiveCell.Row Cells(sls_row, icolumn).Select ActiveSheet.Paste Number = i + 1 Loop Until Application.Goto Reference:="slsperson" & number = error End Sub
I have written a piece of code that sets the print area for the cells whose formulas are not blank as the result of the if formulas in them. The code works across the page.
In it's current state the loop should repeat four times as that is the number of non-blank cells. The loop I have is:
Code: Do While CollSheet.Offset(0, i).Value "" i = i + 1 Loop
This however, gets as far as i = 2 before completing the loop. To test why I wrote the following piece of code which loops the four times it is meant to. The trouble is I can't work why they aren't returning the same value as to my knowledge, they do the same thing. If I had to guess I think it's something to do with the cell being a merged cell.
Code: Do While ActiveCell.Offset(0, 1).Value "" ActiveCell.Offset(0, 1).Select Loop
I would like to use the following code to produce a message with two numbers in it, both showing an exact golf handicap to one decimal point. If a number is exactly 6 I want it to show as 6.0.
All works well for the number I'm collecting from the user and storing in newh. But I can't retain/produce the trailing zero from oldh which is formatted in the spreadsheet as Custom 0.0.
I am looking for a macro or a formula that can give me multiple tabs, what i need is jan 01 to april 30,the next 2 books i could do by copying of course i have looked at the macros on here and no nothing about them ....
I am trying to run for_each_loop to in a module run an activity on other excel file.
Other excel file is having 8 sheets and loop is working fine till 4th. but when loop goes to 5th sheet it says Application defined or object defined error. I am confused because i have defined the objestSh as worksheet in the beginning.
I am trying to fill an array with only a few values within a loop (when XspacingA is 0.5, add the value of the Line to the array) and keep getting the error "Subscript out of range".
I have some code that is working great except that it throws up an error on the last run through because it doesn't find any more rows to delete. I've tried "On Error GoTo" but it doesn't catch it. It seemed to work on my home computer which is running Excel 2010 but then on Excel 2007 I get the debug screen and I don't want that to show up for other users that I share the code with.
Sub DeleteHeaders() Dim lastrow As Integer lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row
I am running regression statistics for several different columns of data. In order to help me analyze the data, I am organizing the output on a specified worksheet called "Best Subset." I have stored the column names of the data used in different regression calls in a range array called Reg_Labels. The Reg_Labels array may contain one, two, or sixteen column labels in one specific location (where each column label is stored in a separate cell). All possible column names are stored in the Labels array (each name is stored in a separate location). I basically need to check to see which column names were present in a particular array location in Reg_Labels. When a column name from a cell in Reg_Labels(I-1) matches a column name from Labels(K), I am placing an "X" on the designated spreadsheet to indicate which variable(s) has been used.
My For..Each Loop will not work for some odd reason, and I need to figure out why. I keep getting an error that an object is required. I need each cell in Reg_Labels(I-1) compared with Labels(K), and I thought the For..each loop would be the easiest way to do it.
I just don't understand what's going on if C is a range object and Reg_Labels(I-1) is a range object. Wouldn't this loop supposedly cycle through every cell in Reg_Labels(I-1)?
Have I messed up some sort of object reference? ....
I want to make a little chart for easy reference that tells me due dates for projects, based on estimated completion times.
I'm already using NETWORKDAYS to find the amount of working days between today and a due date, but I want to flip the formula around, and I'm having trouble getting the syntax right.
For example, column A reads:
0 1 2 3 5 7 10 15 20
Estimated completion times for various projects.
So I want column B to read the date that this would render. A1, value 0, would always produce today's date for B1. B2 would always read one business day into the future, B3 would read as 2 business days into the future, B4 as 3 business days into the future. Does that make sense, and B5 as 5 bd into future.
s/s is very large and the need is to transfer formulas from one column to another. Column L contains formulas in cells L7:L45 (attachment) - (L7:L326415 in working s/s). Some of these formulas result in a value being given. I need to transfer formulas only from those cells having values to cells three columns to the left on the same row. I do have code which I was using for another application. This puts a formula in the correct places but it is the wrong formula and I don't know how to amend it so that it carries out the required action. Small attachment enclosed for better understanding of what is involved. Or could anyone change the line ".formula = ......" in the following code to make it work??
I have a workbook that if I use just the array formula for the totals it works fine and if I use data validation and vlookup and the array formula for the totals it is giving me a #Value! instead. I have tried a couple of things and did find that as long as I do not use the vlookup in the one column (column d) the array formula at the bottom works but as soon as I add the vlookup to column D I got the error.
I want to use the vlookup to get the values for items on a different page - along with the data validation and then use the array formula to get a total for multiple items in the above columns. I have attached a workbook.
My objective is to create a "guide or cheat sheet" for the correct combination of various tools.
My user has to choose (1) Mother Tool and (2) If the tool is to be used uphole or downhole.
I need the spreadsheet to automatically limit the choices for Combinability that corresponds to uphole or downhole. After selecting Combinability, the 4th ComboBox must automatically limit the choices specific to subs that fall under the tool chosen under combinability.
I can create a spreadsheet and color-code the combinations however it will be very busy as the list is very long.
I wanted to use ControlBoxes but I can't get it to work - my brain can't seem to connect the dots in VBA.
I wrote a chart formatting macro, which works when applied to a specific sheet, and I'm trying use it in a for each loop. The macro is supposed to loop through a list of sheets and only format chart 1. I'm getting a "run time error 438: object doesn't support this property or method" at this line:
Code: Sub UpdateTextAllStateCharts() 'This macro loops through worksheets in a list and performs the assigned task Dim sheet_name As Range For Each sheet_name In Sheets("WS").Range("C:C") If sheet_name.Value = "" Then