View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default Problems with a Run-time error of 1004....

I am wondering if this is the same project for which I posted code for you on
Dec 24. At that time you said it was a csv file so maybe not; or perhaps with
the current problem of Microsoft Communities not sending notifications you
cannot find my reply.

Just in case, if you cannot find your reply, log into the newsgroup. If
after logging in you get an error message that the page cannot be displayed,
click the refresh button.

After logging in click the 'Edit my profile' button (just to the left of
Help and SignOut) and scroll down and click the link 'Show all my
notifications'. The most recent ones will be at the bottom. Click the link to
the required thread.

Anyway to answer your question here. You have not said which line is giving
you the error but I suspect it is Selection.Insert Shift:=xlDown.

You need to select a row where you want the rows inserted something like the
following.

Rows("12:12").Select
Selection.Insert Shift:=xlDown

At this point in time I will not attempt to confuse you be re-hashing your
recorded code but you should be aware that it can be coded better.

--
Regards,

OssieMac


"CB" wrote:

Hello,

I'm trying to do something I thought was pretty simple, but guess not...

I am trying to copy an area in one file (input file) and then paste those
contents (insert cells) into a master file.

So, in the master file, I need the paste to insert however many lines are in
the buffer....

Anyhow, I'm getting the 1004 error. At work, as long as I am in a certain
cell of the master file, it worked, but at home, this version of Excel
doesn't ever work (2007 I think, it's got the ribbon thing so finding
anything is an extra 30 mins).

I've got to think there's a consistent way to insert the copied cells, but
if not, maybe there's another way to get that data into the master file?

thanks,
Chris

Here's the macro I am working with:



Sub Macro1()

'

'

' Macro1 Macro

' Macro recorded 12/23/2009 by Chris Powers

'

' What this doesn't address:

' 1) selecting file to import

' 2) separating expenses & deposits

' 3) determinng what column an expense should
go in

'

'

' I have this broken into multiple parts, otherwise I'll get a
1004 error every time.

'

' First part, open file, remove top 7 rows, get rid of
unneeded columns, save, close

'

'

'

Workbooks.OpenText Filename:="C:\TEMP\Dec Exp Tracker.TXT", Origin:=437, _
StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True

Rows("1:7").Select

Selection.Delete Shift:=xlUp

Columns("F:F").Select

Selection.Delete Shift:=xlToLeft

Columns("C:D").Select

Selection.Delete Shift:=xlToLeft

'

'

'

'

' Here I try to insert a column so this data lines up with Master file -
this always generates 1004 error.

'

' Range("A1").Select

' ActiveCell.FormulaR1C1 = "delete"

'

'

ActiveWorkbook.Save

ActiveWorkbook.Save

ActiveWorkbook.Close

'

'

' Second part, re-open file I just had open, select data, copy
it

'

' Move back to master file to it's current cell, paste data

'

Workbooks.Open Filename:="C:\TEMP\Dec Exp Tracker.TXT"

Rows("1:1").Select

Range(Selection, Selection.End(xlDown)).Select

Selection.Copy

Windows("C & A Tracker.xls(2)").Activate

Selection.Insert Shift:=xlDown

ActiveWindow.SmallScroll Down:=-21

End Sub