Run Time Error When Copying Rows Based On Word
Jan 10, 2009
Here is my table which is just a test sample of the larger table, but in the end, it is column 1 I want to base the new ws on.
Before Macro
AY *AB1UnitCount2533210431 LGR SQ10584631 LGR SQ7726 Excel tables to the web >> Excel Jeanie HTML 4
The code below works fine through the first instance of the match and adds a new ws based on the name, but when it gets to the second match the macro tries to add the ws all over again and I get a run time error 1004 which states you can not add a ws and name it the same as one that already exist. I only have one sheet in my wb titled "AY". How can I also have the two column headers transfer to the new ws?
Public Sub CopyUnit()
Dim N As String
Dim i As Long
Dim ws As Worksheet
Set ws = Sheets("AY")
N = Worksheets("PAS Codes").Range("L14").Value
For i = Range("A65334").End(xlUp).Row To 1 Step -1
With ws
If Cells(i, 1).Value = N Then
.Rows(i).Copy
Sheets.Add.Name = N
Rows("1:1").Select
ActiveSheet.Paste
End If
End With
Next i
Application.CutCopyMode = False
End Sub
After Macro
31 LGR SQ *AB1UnitCount231 LGR SQ7331 LGR SQ10 Excel tables to the web >> Excel Jeanie HTML 4
View 9 Replies
ADVERTISEMENT
Jan 16, 2007
I am trying to copy rows that contain a specific word from one worksheet to another.
View 9 Replies
View Related
Jan 16, 2007
I am trying to copy rows that contain a specific word from one worksheet to another.
View 9 Replies
View Related
Feb 11, 2010
I've been trying to use the below code,
Sub combine()
'This will copy data from all sheets of the selected workbooks
'To a sheet named 'Data' in the sheet in which the macro is run from
Dim pasterow As String
mainsheetname = ActiveWorkbook.Name
MsgBox ("Please select spreadsheets to combine")
filestoopen = Application.GetOpenFilename(MultiSelect:=True)...
View 9 Replies
View Related
Feb 27, 2014
I am using the below macro to copy the rows (Starting from Row 2 excluding header row) to another sheet (Starting from Row 2 excluding the header row). I have a huge number of rows which i need to copy to the new sheet (crossing 1.5 Lakh records) which is probably causing "Out of Memory Error: 7" to occur when i execute the below code.
[Code].....
View 14 Replies
View Related
Oct 30, 2013
I am using a Pivot Table to search for keywords in a subject line and it will display results if that keyword appears in the Pivot Table.
What I want to be able to do is copy 30 cells of that Pivot Table at a time into a new Workbook. All that I want to copy is Column A(Case Number) and Column B(Subject Line) of the Pivot Table.
Example:
Total Pivot Table data is 1000
I search for "Crashing", this will display 100 records
I want to grab the first 30 records and copy them into a new workbook
I want to grab the next 30 records and copy them into a new workbook
I want to grab the next 30 records and copy them into a new workbook
I want to grab the remaining 10 records and copy them into a new workbook
View 9 Replies
View Related
Sep 2, 2013
I am using Windows 7, with Excel 2010.
I have one Worksheet Short Course - PB's Which contains all swimmer information and searches through all previous swims and reports back the swimmers current Personal best times (PB)
I am creating a work sheet to calculate percentage increases over a set date period. I have managed the calculations but can not get the autofill to function as I was hoping.
In my short course sheet 1 Row = a Swimmer and there details
In my new sheet, I have 3 rows for the same swimmer
Row 1= Swimmer and PB's before a set date
Row 2 = Swimmer and PB's After set date and upto Todays date
Row 3 = Percentage calculation of difference between the two rows to enable track performance increase
I have all of this working and in place and want to copy the formula's down now to cover all swimmers in the club.
When I copy the 3 lines down, Autofill adds 3 to the row reference for the first line and I just want it to add 1.
ROW3) =IF('Short Course - PB''S'!A3="","",'Short Course - PB''S'!A3)
ROW4) =A3
ROW5) = A3
[Code].....
View 4 Replies
View Related
Jan 21, 2009
I'm not the sharpest tool in the shed when it comes to excel programming but I manage. However, I can't seem to get rid of this run-time error 13. Could anyone take a quick peek at the document and spot the problem?
My intention is this, when typing 'Yes' in the AB column on a certain row, that row is cut from that worksheet and moved to the 'Archive' worksheet, also, simultaneously, I want to send a mail to a specific address.
Here is when I run into the error, I suspect when the row is removed with the 'Yes', those two macros clash.
View 6 Replies
View Related
May 21, 2014
I have a sheet with a lot of different data. In column M in workbook "Maximo report" there are 5 different values. I want to copy the rows that contain CDC_HVAC and that have the value "INPRG" in column G to the sheet HVAC_INPRG. I want to do this for all 5 values. Once the rows are in their respective sheets I want to filter them based on a formula and then sort from oldest to newest. I dont want the file to be too big and I think that VBA is the way to do it. I am new to VBA
View 6 Replies
View Related
Sep 27, 2009
Run time error 1004 when adding rows. I have the following code, called from a Userform:
View 4 Replies
View Related
Aug 27, 2006
I would like to copy selected rows in a range D19:I49 to another sheet, by clicking a button to bring up a User Form containing a List Box, seven Option Buttons (one for each sheet), an OK and Cancel Button. When the User Form is displayed, the required rows are selected in the List Box, then the required sheet is selected via an Option Button. Upon clicking the OK button it pastes (only the values) to the selected sheet, but to the next empty row (if there is already data entered previously) in the same range as above (D19:I49). All seven sheets are identical and are named Monday, Tuesday, etc. to Sunday. If the option button selected is the same as the active sheet a message box could be displayed to ask the user to select another option button and upon clicking the OK button on the message box return the user to the User Form once again so that the correct option button may be selected.
View 2 Replies
View Related
Apr 3, 2008
I'm trying to run this macro and I keep getting the "Run-time error '1004' Application-defined or object-defined error"
I am just trying to hide the rows that do not contain anything in them with this
x = 2
Sheets("sheet2").select
If Cells(x,1).value = "" Then
Rows("x:x").select
Selection.EntireRow.Hidden = True
Else
x = x +1
End if
The line that is giving me a problem is "Rows("x:x").select". but when i change x to an actual number, it works. I cannot have a definitive number because where there is data will vary every time this is ran.
View 9 Replies
View Related
Aug 14, 2009
On sheet "Create Package" in cell "AA14" I have a value (lets say 2).
I want it to go to sheet "Samples" and insert a number of rows equal to the value on sheet "Create Package" cell "AA14" (so 2 rows)
I have a header row in row 1, so I would like it to insert the designated number of rows beneath that.
Then I would like it to copy a designated number of rows (based off of the "AA14" value, so 2) from the "Create Package" sheet starting at row 66 and then paste special values into the new rows that were inserted on sheet "samples".
View 9 Replies
View Related
Jul 27, 2012
I have eight sheets that have lists of questions in, which I want to copy across to a results sheet if the answer to a question is 'Yes'. Each question takes up rows B:H inclusive, and I would want to copy them to rows B:H in the results sheet. The "Yes" value will be found in column F of each row.
How can I set up a macro to copy the entire rows (without formatting) into a results sheet properly? I've tried every solution I can find but always hit a roadblock somewhere.
Ideally I would like to have a 'populate' button on the results sheet that would find every question that was answered 'yes' across the eight survey sheets and import them into results sheet.
View 2 Replies
View Related
Dec 27, 2008
I have data in Column J1:J90, I use a macro to open the word document.
Would like that data in Column J may be pasted in word document in text form automatically. such as:
abc
cdc
xyz
may be pasted as, abc cdc, xyz etc.
The macro is:
View 2 Replies
View Related
Oct 29, 2009
I'm trying to copy an ELOOKUP formula down a column in a sheet. The formula is losing part of the table array when I carry it down and returning an N/A error. Interestingly, it will work when I copy it across a row.
View 9 Replies
View Related
Apr 11, 2013
I have a set of 3,000 data points. The data is in one second intervals, however I am interested in seeing what the data looks like in a graph if I only had a point every minute. I have the following set up.
A B C
TIME X Y
What I want to do is to leave the first cell unhidden, and then hide the next 59. And then repeat this so I narrow the data down to one second each. I'm looking to do this multiple times, so I can create a graph each time in order to get an idea of what the data would look like if I only had a point for every minute.
Is there a macro that I could write, that would hide every cell except every 60th one? I was thinking that I could hide it based on the time. What would the code look like if my time was in 00:00:00 format? It's increasing, so I need it to hide cells that aren't equal to XX:XX:01, for example.
View 3 Replies
View Related
Feb 9, 2007
I have three columns - "Start Time", "End Time", and "Elapsed Time". Elapsed time is just end time - start time. What I would like to do is insert rows based on elapsed time.
For instance if start time is 6:00 and end time is 6:10, then elapsed time is 0:10. In this case I would like to insert 10 rows below. Basically I want to insert 1 line per minute (based on elapsed time).
View 9 Replies
View Related
Sep 26, 2011
I have code that is trying to open a word document and paste it into an email body. If I use plain old control v it works fine but using the method below, I loose my images and my formatting. Is there a way to use send keys here or some other method to preserve my formatting when getting the text to the body of the email?
Code:
Private Sub DREmail_Click()
Dim OutApp As Object
Dim OutMail As Object
Dim attachmentQ As String
Dim oWord As Object
Dim wdapp As Word.Application
Dim DRloc As String
Dim DRText As DataObject
[Code] ........
View 2 Replies
View Related
Jan 8, 2013
I am creating many tables in excel using a macro, and I want to copy them into a word document for later use. All the tables come from a long list, so for simplicity, they all get created on the same range starting at F1. Before deleting the existing table and adding the new one, I'm trying to copy/cut the table and paste it into a word document.
In case it makes a difference, I have office 2007
VB:
Sub ExcelToWord(LastRow)
Dim objWord As Word.Application
Range("F1:F" & LastRow).Copy
With objWord
.Documents.Add
.Selection.Paste
.Visible = True
End With
End Sub
View 6 Replies
View Related
Mar 19, 2014
Below is an example of an Excel sheet I'm working with: [URL]
Basically, I'm trying to delete the duplicate rows by matching ID, Date and Type. If ID, Date and Type are the same, then, I want to only keep the record with the earliest Time in case of Type = In and the latest Time in case of Type = Out.
So, for example, in the case of ID = 1, there are 3 records for In, I only want to keep the one where Time is: 8:01 as this is the earliest. The other 2 records should be deleted.
Similarly, in the case of ID 3, I want to keep the record where Time = 18:05 as this is the later time out of the 2.
Can this be achieved by Conditional Formatting or Macro or VBA?
View 1 Replies
View Related
Apr 10, 2013
I am working on word documents that has financial numbers on them. I am copying word pages to excel to calculate the numbers by using formulas and etc. I will cut to the chase; is there a way or a macro to insert into an excel template workbook(.xltx) when we open the template there will be a command button to select the word document (which we want to copy its pages) to excel sheets. When a new page begins a new sheet will be created and the page will be pasted on the new sheet.
It is not important if it has to have a command button to select the word document it is ok to run the macro and select the word document and it does not has to populate sheets according to length of word document (I can create lost of free sheets on the template)
The main idea is to gain the time I spend on copying the word document to excel sheets. Some documents can be very long (100 pages). I am using MS Office 2007.
I triend to export data but excel does not allow me to select word documents.
View 5 Replies
View Related
Oct 8, 2008
I have written a Excel (2003) that searches a worksheet for a string in any cell. If the string is not found, it uses the 'On Error GoTo' command to jump to a given label. It works fine on the first string not found. When it searches for the next non-existent string, it fails with:
'Run-time error '91':
Object variable or With block variable not set'
Do I have to clear a buffer after each cells.find search?
My
View 7 Replies
View Related
Oct 10, 2006
I'm not sure why this is happening, but every other time I run this one specific macro, I get a "Run-time error '1004': Paste method of Worksheet class failed". I even tried running this macro, then running a different one, then running this again, but I still got the error every other time.
Every time I get the error, it highlights this line of
Sheets("Regenerate Request").Paste
This is all of the code up to where I get the error:
Sub YesRegen()
' after user has hit Yes on the RegenerateRequest macro, this posts the new request to
' the log, generates the new file and attaches it to an email
Application.Run "LogUnprotect"
Range(Range("A" & ActiveCell.Row), Range("K" & ActiveCell.Row)).Copy
'Selection.Copy
Sheets("Regenerate Request").Activate
Application.Run "RegenFormUnprotect"
Range("A40:K40").Select
Range("A40").Activate
Sheets("Regenerate Request").Paste
View 10 Replies
View Related
Feb 29, 2008
I'm using a loop to populate formfields in a word document from an excel userform. Each control on the userform has an equivalently named formfield in the document.
I have a problem using the following piece of
For Each myControl In myPage.Controls
wdDoc_App.FormFields(myControl_Name).Result = myControl.Text
Next myControl
I get the error "The requested member of the collection does not exist."
The problem seems to be the string variable myControl_Name.
how I can get around this, I don't want to reference each formfield by name.
View 9 Replies
View Related
Aug 1, 2014
I'm building a master data spreadsheet to hold all of our data for the next fiscal year. There are about 300 data elements divided by month (our fiscal year is July-June). The intention is to go in monthly and enter data. How do I create the formulas and then copy them across the rows without getting the #VALUE! error or #DIV/0! error since I don't have data in the columns yet? Ideally, I'd like the formulas to live in the background and have the cells blank until I enter data for the particular month.
If it matters all my formulas are something similar to =IF(B4 = " ", " ", B4) or =IF(B4 = " ", " ", B4/B5)
View 2 Replies
View Related
Jan 26, 2010
1) The following code works well except for 1 wierd circumstance. This UDF code resides in a Cell in workbook 'A'. If I have another workbook open (call it workbook 'B'), and I do ANYTHING in workbook 'B' (like copy a cell to another cell within workbook 'B', or perform a calculation within workbook 'B', or even copy a cell from 'A' to 'B'), then the cell that this UDF resides in (workboook 'A') will change from a good number to a #VALUE error. If I work ONLY within 'A', then this UDF functions properly (giving a good result).
2) If I hit the F9 button (i.e. re-calc), with workbook 'A' active, then the #VALUE goes away, and the good number comes back. To clarify, all workbooks have AUTO CALC enabled. I guess the 'Application.Volatile' line causes this code to run when I hit the F9 button (thereby clearing the #VALUE error). If I hit F9 with 'B' active, then the #VALUE error (back in 'A') goes NOT clear.
3) NOTE #1: If I put a BREAKPOINT inside this code, and then repeat a "copy from cell to cell" within workbook 'B', I find that the following code DOES NOT execute, as it does NOT "stop" the code at the BREAKPOINT line. But, when I hit F9, then it DOES stop at the BREAKPOINT.
4) NOTE #2: If I "comment out" the Application.Volatile line, it still does the SAME thing. Except worse, then when I hit F9, it doesn't correct the #VALUE error. I really need the Application.Volatile step with this code, as these functions will not automatically update if their referenced cells are changed.
5) NOTE #3: The variables Row_Num & Column_Num are declared at the Module Level. If I use unique variables and declare these at the Procedure Level, it makes NO difference. I also tried putting a "DoEvents" line after Application.Volatile, but NO difference.
6) It seems I need this code to execute whenever there is a "change" on ANY workbook. Or else, do something to keep these cell values from changing anytime there is "action" on another workbook. Or, is there better code to do the samething? ... Do you have any CLUE how to fix this SNAG?
View 13 Replies
View Related
Jan 9, 2008
I got a code to delete all rows in the sheet which contain the word "DETAILS" but I now want to delete all the rows that do not contain the word "DETAILS"
My code if needed is:
Sub Find_details()
Dim rng As Range
Dim what As String
what = "DETAILS"
Do
Set rng = ActiveSheet.UsedRange.Find(what)
If rng Is Nothing Then
Exit Do
Else
Rows(rng.Row).Delete
End If
Loop
End Sub
View 9 Replies
View Related
Aug 25, 2009
I have a spreadsheet with about six sheets.
On sheet one: I am entering data.
On sheet two: I am running the following macro: The macro is copying formula from row 6 to the a row number specified in cell A5......
View 9 Replies
View Related
Aug 7, 2007
I have a number of Vlookups in sheet1 book A (originally created by someone else). When I use Move or Copy to copy sheet1 to workbook B all the vlookups show as =#N/A. Guess this is a setting somewhere?
View 7 Replies
View Related