VBA Insert New Row Below Active Cell Error 1004

KWHAT

Registered User.
Local time
Today, 13:14
Joined
Dec 7, 2011
Messages
19
Hey everyone thanks for your help in advance, im trying to insert a new line below the active cell ive tried several attempts but i am getting error 1004. Some attempts are commented out.


Code:
           wks6.Activate
                        With wks6
                            .Select
                           ' .Rows.AutoFit
                           ' .Columns.AutoFit
                            .Range("A:AO").Select
                          With Selection
                              .HorizontalAlignment = xlCenter
                              .VerticalAlignment = xlCenter
                              .WrapText = True
                              .Orientation = 0
                              .AddIndent = False
                              .IndentLevel = 0
                              .ShrinkToFit = False
                              .ReadingOrder = xlContext
                              .MergeCells = False
                          End With
                             '.Range("AB").EntireRow.Offset(1, 0).Insert
                             '.Range("AB").EntireRow.Insert shift:=xlDown
                             .Range("AB").Select
                              Selection.EntireRow.Insert Shift:=xlDown
                        End With
 
This is an Access forum. Since this is an Excel VBA question, you might get a better answer in an Excel forum. When I want to automate Excel, I open Excel and attempt to perform the action using the interface. Once I can do it smoothly, I turn on the macro recorder and do it again. I then take the VBA generated by the macro recorder and modify it for use with Access.
 
This is an Access forum. Since this is an Excel VBA question, you might get a better answer in an Excel forum. When I want to automate Excel, I open Excel and attempt to perform the action using the interface. Once I can do it smoothly, I turn on the macro recorder and do it again. I then take the VBA generated by the macro recorder and modify it for use with Access.

The code is placed in a Access 2007 Application, ive already attempted to record a macro from Excel and insert it into Access, however this does now work. i Still receive the error issues in access error 1004.
 
You haven't told in which line you get the error, but it can be a question about trust/securities.
Look at the article in the link: http://support.microsoft.com/kb/813969


As i mention above it's an error when "im trying to insert a new line"

Code:
Selection.EntireRow.Insert Shift:=xlDown
I have other lines of code accessing the Excel file change the background color and re-size the columns, this works perfectly and i verified the trust/securities setting prior to asking this question.
 
.Range("AB").Select

is an invalid command. (besides AB is a column - you want to insert a row).
 

Users who are viewing this thread

Back
Top Bottom