Grid Line Issue in Excel Sheet

The Problem is that I have so many sheets in One workbook . I want to set for only one Sheet the gridline .but in Other Sheets Grids needs to be Come Automatically .So let me know the idea .how should I achieve this specific task using Macro ???.any help would be highly appreciated .Kindly see the attachment also .if you will Print Preview to Mamasita Calenderata sheet or Mamasita Tamarind mix . you will see the grid at the time of Print Preview but if you will see the Print Preview to tomato Sauce Sheet .you will not get the Grid in full page .So let me know please !!! .

Post your answer or comment

comments powered by Disqus
I need a report to be created as the same in the excel sheet

how to do this

On an application i am working on, i am having problem importing an excel sheet to access.
The problem goes as follows:

If the excel sheet contains any blank fields like shown below

dkjhf kjshdfkjh kjhdkjhfjkd hkjhdjkfhkjh kjhskjfghlk
ff f
df df s df

then the sheet imported is access is completely blank.

Pls help if you have any idea how to resolve this problem...

The specific line of code i am using to do so goes as follows

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Rates ", Directory + "Sapp.xls", False

Hello Everyone

I am quite new to the world of VB coding in Access. I have written down a code to Import Excel sheet into Access07.

The table has been made accordingy and it works fine. it imports the worksheet "closing12" to tables 'Fixed_Asset_Listing' and 'NBV_Fixed_Asset_Listing'.

I am having problems writing code for deleting column name "sortfield" from the excel sheet. Here is a twist. the reason I want to do so is because the excel sheet generated from the software can have as many sortfields as user want and will be names as sortfield1, sortfield2, sortfield3 and so on.... it is garbage data and I want to delete all the columns with name sortfield1, sortfield2, sortfield3 and so on.... before i do the import process.

While Mid(xlSheet.Range("A2").Value, 1, 9) = "Sortfield"

Please help me with correcting the added code. Ur help will be really appreicatated.

Whole code is written down.

Thanks and Regards,
Prashant Kumar.

Private Sub Import_Fixed_Asset_Listing_Click()
Dim filename As String
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
sFilter = "Excel Files (*.xls)" & Chr(0) & "*.XLS" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:"
OpenFile.lpstrTitle = "Import Fixed Asset Listing"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "No File Selected. Abort!"
filename = Trim(OpenFile.lpstrFile)
DoCmd.Close acTable, "Fixed_Asset_Listing", acSaveYes
Set xls = CreateObject("Excel.Application")
Set xlWB = xls.workbooks.Open(filename)
xls.Visible = True
Set xlSheet = xlWB.Worksheets("Closing12")
While Mid(xlSheet.Range("A2").Value, 1, 9) = "Sortfield"


DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
"Fixed_Asset_Listing", filename, True, "Closing12!"

DoCmd.OpenQuery "Delete_Querry(data_of_table_NVB_FAL)"
DoCmd.Close acTable, "NBV_Fixed_Asset_Listing", acSaveYes
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
"NBV_Fixed_Asset_Listing", filename, True, "Closing12!"

Set xlWB = Nothing
Set xls = Nothing

End If
'Transfers file using acImportDelim profile previously set through manually importing into table
'DoCmd.TransferSpreadsheet(acImport,acSpreadsheetT ypeExcel8,"temp",filename,0,"A2:v67",1) =
End Sub

I have an Excel sheet that I'd like to bring into an Access Form -- populate the Excel cells with data from textboxes on the Access Form and print it. I tried copy/pasting various things in, but it's pasting even text from a cell as an Excel object (let alone joined cells and images). Where can I find more information about this?

I found
But, when I put that code into the form for saving text from a text box to an Excel cell, it tells me that the word "Set" is a "Compile error: Invalid outside procedure."

Also, how do I refer to a joined cell? I've found that I can copy from a joined cell, paste into a host cell and select "Paste Link". This puts an absolute reference to the joined cell in the host cell (=$A$7, for instance) and when I change the joined cell the host cell is changed. Pasting =$A$7 seems to merely put the face value of "=$A$7 into the host cell.

Dear All,

I need small help from you. In Excel sheet i do have about 1000 records.In that 1000 records, i need to categorize the one particular cell value.

For Ex,

A1 cell value "Password Reset" then b1 cell would be "Related to PWD"
B2 cell value "Access to system:" then b1 cell would be "Related to access".

i do not know the condition for the cell "contains"

If a a1 to a100 contains the word "Password" then automatically it shud fill in b1 to b100 "Password Reset"

tired of filling 1000 records.

if anyone helps on this would be appreciated.


Please help! How do you set a checkbox in Excel sheet to True from Access?

Hi All,

In excel sheet i have a chart and table for which I am setting data range property at design time.based on the data i want to set it at run time.

select in chart menu---> Source data --> Data range property we are setting at design time. How to set this property at runtime. Please refer the attachment.

could you please help me.

Thanks & Regards in advance,

I am using some code that I have changed up to get to the last row of data on a excel sheet. I can get to the last cell with no problem but I am having an issue going a row beyond it to the next blank row. When I run the following I get a - Run-time error '424: Object required on the intNewRow line. Any ideas on what may be causing this? Thanks for the help!!

Public Function test123()

Const xlCellTypeLastCell = 11

Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Open("C:Documents and SettingsTest.xlsx")
ApXL.Visible = True

Set xlWSh = xlWBk.Worksheets("Test123")

Set objRange = xlWSh.UsedRange

intNewRow = objExcel.ActiveCell.Row + 1
strNewCell = "A" & intNewRow

End Function

Does anybody know how to select all the blank lines in an Excel spreadsheet that come after the data and delete them? This may seem like a stupid question (probably is) but here's the story. I'm importing sheet2 of the spreadsheet into Access, deleting certain rows and then exporting back to sheet2 in the spreadsheet, all works fine except when I try to run a DTS package in SQL Server, I get an error. But, if I open the spreadsheet manually and mark up all rows beneath the data and delete them (even though they're blank), the DTS package runs fine

Very grateful for any help, it's driving me nuts!! Below is the code I'm currently using...

	Sub sCopyRS()

Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim db As Database
Dim rs As Recordset
Dim intLastCol As Integer
Const conMAX_ROWS = 20000
Const conSHT_NAME = "Shipping Details"
Const conWKB_NAME = "H:BIDataLoadSupplier Orders.xls"
  Set db = CurrentDb
  Set objXL = New Excel.Application
  Set rs = db.OpenRecordset("Shipping Details", dbOpenSnapshot)
  With objXL
    .Visible = False
    Set objWkb = .Workbooks.Open(conWKB_NAME)
    On Error Resume Next
    Set objSht = objWkb.Worksheets(conSHT_NAME)
    If Not Err.Number = 0 Then
      Set objSht = objWkb.Worksheets.Add
      objSht.Name = conSHT_NAME
    End If
    On Error GoTo 0
    intLastCol = objSht.UsedRange.Columns.Count
    With objSht
      .Range(.Cells(2, 1), .Cells(conMAX_ROWS, _
      .Range(.Cells(1, 1), _
        .Cells(1, rs.Fields.Count)).Font.Bold = False
      .Range("A2").CopyFromRecordset rs
    End With
  End With
  Set objSht = Nothing
  Set objWkb = Nothing
  Set objXL = Nothing
  Set rs = Nothing
  Set db = Nothing
End Sub


Hi All,
I hope you could help with this.

I am having a querry in access with 131000 lines, which obviously is too much for excel and for what I need, I would like a process which can cut it every 5000 or 4000 lines (if I can choose the amout better) the access doc and divide it in differents excel sheets.

Does anyone have any application/process/methode to run in access?


Hello all,

I am having a querry in access with 131000 lines, which obviously is too much for excel and for what I need, I would like a process which can cut it every 5000 or 4000 lines (if I can choose the amout better) the access doc and divide it in differents excel sheets.

Does anyone have any application/process/methode to run in access?


May somebody help me, I want to write sheet name in excel file with the item was choosed in combo box, when running docmd.outputTo

Please help


Is there an easy way to add grid lines to my report ?? (like in excel) I'm running Access 2003

Thank you


hi.. friends...

I m access user... i have made some queries.. & want to transfer data from different queries to on excel file in different sheets.. I have tried transfersheet macro... but... it transfers with one inverted coma in text column.. due to this the data exported to excel is no use to me.. as i m not able to upload the same to another application or even apply vlook in excel which is my basic purpose for doing this entire thing....

Can any body help me in this...

Hi all, hope everybody is cool

I am trying to extract each line of a memo field in an Access table into cells in excel.

Let's assume the text is in the format:

Status - For follow up []
Assigned To - Mr, Me []
Company - Wewkesbury Ltd []
Company Reg No - 5183464561 []

Where "[]" is a carriage return. How would I loop through each part of the text body? I would then increment a counter to output each line to a new cell.

Hope this makes sense!


Can any body point me in the right direction? I'm completely out of ideas.

I import an excel sheet with the following command

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "data", root & "tmp_Query_Output.xls", True

Works fine but for one issue.
I have 6 dates with time in this sheet. 4 come over fine 2 come over with only the date.

I do format the excel sheet seperately before the inputs to the proper date format. The database that receives the data is also set to general date.
But still 4 ok 2 only the date no time.

If I however attach the excel sheet to the db and then use an append query to the same table it works fine.
However I still would like the Transferspreadsheet cmd or at least understand why it doesn't work.

Any body??

Why does the following not delete the listed sheets in excel?

Private Sub cmdbtn_crewebbasexcgra_Click()
Dim xlSheet As Object, myfield As Variant, xlApp As Object, xlWork As Object, Strfile As String
Dim MyDb As Database, MyQuery As QueryDef, strSQL As String
Dim objXLBook As Excel.Workbook
Dim objXLSheet As Excel.Worksheet
Dim Response

Strfile = "c:Documents and SettingsIce RhinoMy DocumentsWork RelatedD2KLiteWebGraphs.xls"

Set xlApp = CreateObject("Excel.Application")
Set xlWork = xlApp.Workbooks.Open(Strfile)
Set xlSheet = xlWork.Sheets("Date_Info")
myfield = Me!txt_dateheader
xlSheet.Cells(1, 1).Value = myfield


Set xlSheet = Nothing
Set xlApp = Nothing
Set xlWork = Nothing

Anybody got any ideas?


Originally posted under Macros and now I realize the answer is probably to use VBA. My problem is I have little to no knowledge of creating code.

I have an export function that exports the contents of 11 different forms to 11 different Excel Spreadsheets on a regular basis. I use a Macro to do this repetitive function. I have turned off all the messages in Access but Excel puts up a Yes/No warning that the sheet already exists and asks if I want to overwrite it. Yes I do.

How can I turn off these warnings from Excel in an Access 10 Macro?

I have little skill with VB but assume we could ask the Macro to run a piece of code to turn off all Messages in Excel and turn them back on at the end of the process. Further could I run a piece of code to start a specific excel Spreadsheet from the Macro as well. The path would be C:LDP_DatabaseSeneca_Period_Analysis_ExportsCom parative_Analysis.xlsx.

Any input would be greatly appreciated.


I am trying to place 3 stacked column charts into one single chart sheet, i have been able to do this using excel itself but i would like to automate the process from access.

has anyone done this before?

currently i am able to create the the required charts, but not able to add them into one single chart sheet here is some of my current code:

Set container = Charts.add
Set graph = Charts.add
graph.ChartType = xlColumnStacked
graph.SetSourceData Source:=ws.Range("$B$" & int_start & ":$E$" & int_end)
graph.PlotBy = xlColumns
graph.location Where:=xlLocationAsObject, Name:=container.Name

the last line constantly gives me an error, i recorded a macro in excel with the required process to have a look at the code but this did not help!

any help will be much appreciated...

First off i will let you know the reason i am trying to do this. We are trying to keep our test reports better organized and have created a database that stores the data for each test. Fields include Model; Type; Date Tested; Tested By; Test Procedure; Name of Test; Test Results and the like. Each record is stored with that info and i need to be able to transfer it to our ISO9000 approved form that we keep in excel so we can print it off and get it signed by managers and put into record retention.
So with that being said I am trying to solve a problem with transferring the information from a single record on a form into an excel template that is already formatted the way that i need. So far i have been able to get the info from off the form that is being displayed, and using a query i have written the information in one line on a new table. I intend to be able to push a command button on the form and transfer the data into the formatted excel sheet so far i have this.

	Private Sub Command40_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_Export"
DoCmd.SetWarnings True
Dim oExcel As New Excel.Application
Dim WB As New Excel.Workbook
Dim WS As Excel.Worksheet
Dim rng As Excel.Range
Dim objConn As New ADODB.Connection
Dim objRs As New ADODB.Recordset
Const sFileNameTemplate As String = "D:DATAACCESSExcelTemplatesTestReportTemp.xls"
Dim sSQL As String
Set objConn = CurrentProject.Connection
sSQL = "Select * from tbl_Export" 'This has to be the name of the query/table your report is using to display data
With oExcel
    .Visible = True
               'Create new workbook from the template file
                Set WB = .Workbooks.Add(sFileNameTemplate)
                        With WB
                             Set WS = WB.Worksheets("Sheet1") 'Replace with the name of actual sheet
                             With WS
                                      objRs.Open sSQL, objConn, adOpenStatic, adLockReadOnly
                                      Set rng = .Range("A2") 'Starting point of the data range
                                      rng.CopyFromRecordset objRs
                             End With
                        End With
End With
Set objConn = Nothing
Set objRs = Nothing
End Sub

This getting the data from the record that i want and transferring it succesfully to excel but it just puts it in one line starting with the Range that i have specified. I need to split up each cell coming from access and direct them into there coresponding cell in excel. Any Help would be appreciated.


I have been banging my head against a brick wall over this,
I sometimes get given Access VBA code to look at when other get a little stuck.

I'm by no means an expert, the reason is that the code they usually find problems with is manipulating Excel objects and that where I come.

BUT, I have of been give a few files that are trying to add charts to an existing template and have experianced the same problem over and over.

All the files can pass the data to a worksheet BUT when I/they/we try to set the SourceData of th Chart good old runtime 1004 pops up to ruin the day,
here an example of the line concerned;

.SetSourceData Source:=Sheets("Progress Report").Range(myRange), _

this doesn't happen all the time but at least 1 in 20 times.

Does anyone have any experiance of this, any work arounds.
The annoying thing is that I know the code is good, I can run it from within Excel, replacing the myRange with a set range.

Here's the whole code incase it something else triggering it:

Private Sub PerformanceAnalysis()

Dim Weeks As Double, Remainder As Boolean, i As Integer, rstemp As Recordset, StartDate, StopDate As Date, arrPerf(), qdquery As QueryDef
Dim sql, ByTM, ByAccount, CallType, ByCSP, ChartTitle As String, Monitored As Integer

Set qdquery = CurrentDb.QueryDefs("qryProgressByAccount")

sql = "SELECT Avg(Main.BodyPer) AS AvgOfBodyPer, Avg(Main.SummarisingPer) AS AvgOfSummarisingPer, Avg(Main.TechnicalPer) AS AvgOfTechnicalPer, Avg(Main.OpeningPer) AS AvgOfOpeningPer, Avg(Main.OverallPer) AS AvgOfOverallPer FROM Main WHERE (((Main.CallDate) Between GetBeginDate() And GetEndDate())"
ByAccount = " AND ((Main.Account)=GetAccount()))"
ByTM = " AND ((Main.TeamManager)=GetTM())"
ByCSP = " AND ((Main.CSP)=GetCSP())"
ChartTitle = ""
If Not IsNull(Me.cmbCSP) Then
sql = sql & ByCSP
z_CSPName = Me.cmbCSP
ChartTitle = z_CSPName
End If

If Not IsNull(Me.cmbAccount) Then
sql = sql & ByAccount
z_Account = Me.cmbAccount
If ChartTitle "" Then
ChartTitle = ChartTitle & ", " & z_Account
ChartTitle = z_Account
End If
End If

If Me.chkQA = True Then
If Me.chkTM = True Then
Monitored = 0
Monitored = 1
CallType = " AND ((Right([CallCoach],4))=" & Chr(34) & "(QA)" & Chr(34) & ")"
End If
If Me.chkTM = True Then
Monitored = 2
CallType = " AND ((Right([CallCoach],4))" & Chr(34) & "(QA)" & Chr(34) & ")"
End If
End If

If Monitored > 0 Then
qdquery.sql = (sql & CallType)
qdquery.sql = (sql)
End If

If Not IsNull(Me.cmbTM) Then
qdquery.sql = qdquery.sql & ByTM
z_TM = Me.cmbTM
ChartTitle = ChartTitle & ", (" & z_TM & "'s team)"
End If


z_BeginDate = Me.txtBeginDate
z_EndDate = DateAdd("d", 1, Me.txtEndDate)
StopDate = z_EndDate
StartDate = z_BeginDate

ChartTitle = ChartTitle & " Analysis, " & StartDate & " - " & DateAdd("d", -1, StopDate)

If Me.chkQA = True And Me.chkTM = True Then
ChartTitle = ChartTitle & " , (QA & TM Calls)"
If Me.chkQA = True Then
ChartTitle = ChartTitle & " , (QA Calls only)"
ChartTitle = ChartTitle & " , (TM Calls only)"
End If
End If

Weeks = (z_EndDate - z_BeginDate) / 7

If Len(Trim((Str$(Weeks)))) > 1 Then
Weeks = Int(Weeks)
Remainder = True
Remainder = False
End If

z_EndDate = DateAdd("d", 7, z_BeginDate)
For i = 1 To Weeks
Set rstemp = CurrentDb.OpenRecordset("qryProgressByAccount")
If Not rstemp.EOF Then
ReDim Preserve arrPerf(6, Weeks)
arrPerf(0, i - 1) = Str$(z_BeginDate) & " - " & Str$(DateAdd("d", -1, z_EndDate))
arrPerf(1, i - 1) = rstemp!AvgOfOpeningPer
arrPerf(2, i - 1) = rstemp!AvgOfBodyPer
arrPerf(3, i - 1) = rstemp!AvgOfSummarisingPer
arrPerf(4, i - 1) = rstemp!AvgOfTechnicalPer
arrPerf(5, i - 1) = rstemp!AvgOfOverallPer
z_BeginDate = DateAdd("d", 7, z_BeginDate)
z_EndDate = DateAdd("d", 7, z_EndDate)
End If

If Remainder = True Then
z_EndDate = StopDate
If z_BeginDate < z_EndDate Then
Set rstemp = CurrentDb.OpenRecordset("qryProgressByAccount")
If Not rstemp.EOF Then
ReDim Preserve arrPerf(6, Weeks + 1)
arrPerf(0, i - 1) = Str$(z_BeginDate) & " - " & Str$(DateAdd("d", -1, z_EndDate))
arrPerf(1, i - 1) = rstemp!AvgOfOpeningPer
arrPerf(2, i - 1) = rstemp!AvgOfBodyPer
arrPerf(3, i - 1) = rstemp!AvgOfSummarisingPer
arrPerf(4, i - 1) = rstemp!AvgOfTechnicalPer
arrPerf(5, i - 1) = rstemp!AvgOfOverallPer
End If
End If
End If

Dim xlapp, xlBook, xlSheet As Object
Dim MFILE As String

Set xlapp = CreateObject("Excel.Application")
Set xlBook = xlapp.Workbooks.Add("gbnewdials01quality$downl oadProgressReport.xlt ")
Set xlSheet = xlBook.Worksheets(1)

xlapp.Visible = True
xlapp.Application.Sheets("Progress Report").cells(2, "A") = "Account : " & z_Account
xlapp.Application.Sheets("Progress Report").cells(3, "A") = "Date Period : " & Form_frmReports.txtBeginDate & " to " & Form_frmReports.txtEndDate
Dim h As Integer, v As Integer
For v = 7 To ((IIf(Remainder = True, Weeks + 1, Weeks)) + 7)
For h = 0 To 5
xlapp.Application.Sheets("Progress Report").cells(v, Chr$(h + 65)) = arrPerf(h, v - 7)

Dim myRange As String, n As Integer
myRange = "A6:F"
myRange = myRange & Trim(Str$(IIf(Remainder = True, (7 + Weeks), (6 + Weeks))))
With xlapp.Application.Charts(1)
.ChartType = xlLineMarkers
.Location Where:=xlLocationAsNewSheet, Name:="Graph"
End With

With xlapp.Application.Charts(1)
.SetSourceData Source:=Sheets("Progress Report").Range(myRange), _
.HasTitle = True
.ChartTitle.Characters.Text = ChartTitle
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False

For n = 5 To 1 Step -1
If n = 5 Then
.SeriesCollection(n).Border.Weight = xlThick
End If
.SeriesCollection(n).Smooth = True

.Axes(xlCategory).TickLabels.Orientation = 45

.SeriesCollection(4).Border.ColorIndex = 5
.SeriesCollection(4).MarkerForegroundColorIndex = 5

End With

End Sub

This really has got me stumped, so if anyone can help I'd be the most Greatfullest person ever.

Hi, I wonder if anyone could solve this issue for me. I have a module that will export to an excel sheet and place values in specific rows which is fine, however as it stands the exact file path of the excel sheet must be present in the code. the problem with this is that the excel sheets name will be changing from week to week, therefore, requiring me (at the moment) to rewrite the path into the VBA code each week.

So, my query is this; is there a way that the code will look in a particular directory and update any files with a .xls extension contained within that directory?

Your time and input is much appriciated.

OK, I have a tool I've made in Access which spits out data from a form, into an excel spreadsheet and makes a line chart/Graph accordingly.

My issues is that I need to be able to chart a single point on the graph to denote price breaks for software we're purchasing.

Is there any way of coding a vertical line on a line graph in excel... or at least plotting one single point? (if you look at my example, it will be easier to see what it is that I need to do via VBA code)

You see in my chart example I have a vertical line and a balloon display to denote the price point break... but I just drew those in by hand... the rest of the chart was made programmatically.

I'm trying to apply some conditional formatting to some rows in an excel spreadsheet via access vba code.

basically, i have a list of tables, lets say A thru D. I have a routine that exports these tables to separate sheets in an common excel file. I am doing this by looping through a recordset with the table names in it, and exporting each table without changing the name of the destination file. This works fine.

then, I'm calling a separate function which, given the name of the table and the path of the excel workbook, opens up the workbook, activates the appropraite sheet (named for the table it came from), and performs some formatting on the sheet. then it closes the sheet and workbook, and the original routine moves to the next table name in the recordset to repeat the process. this also works fine, except...

there are some lines in the code that attempt to apply conditional formatting the the excel sheet. this works fine on the first time through, but when the original routine then moves on to the next record (table name), i get the "object variable or with block not set blah blah" error we all know and love. so what gives? the loop routine is identical for each table, the only difference i can see is that the file has already been created and has a sheet in it already once i attempt to format the next one. here is the formatting subroutine..

	Function FormatMonthlyHours(ByVal FilePath As String, ByVal strSheetName As String)
Dim xlapp As Object
Dim xlws As Worksheet
Dim xlwb As Workbook
Dim intRow, intTot As Integer
Dim dblhours As Double
Set xlapp = CreateObject("Excel.Application")
xlapp.Visible = False
Set xlwb = Workbooks.Add(FilePath)
Set xlws = xlwb.Worksheets(strSheetName)
With xlws
    .Range("A1", "B1").Interior.ColorIndex = 1
    .Range("A1", "B1").Font.ColorIndex = 2
    .Range("A1", "B1").Font.Bold = True
    .Cells.NumberFormat = "0.00"
    End With

    Range("A2", Selection.End(xlToRight)).Select
    Range("A2", Selection.End(xlDown)).Select

    xlapp.Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)"
    xlapp.Selection.FormatConditions(1).Interior.ColorIndex = 15

    Range("B2", Selection.End(xlToRight)).Select
    Range("B2", Selection.End(xlDown)).Select
    xlapp.Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)"
     xlapp.Selection.FormatConditions(1).Interior.ColorIndex = 15

intRow = 2
xlapp.DisplayAlerts = False
xlwb.Close True, FilePath
xlapp.DisplayAlerts = True
Set xlapp = Nothing
Set xlwb = Nothing
Set xlws = Nothing
End Function

If I remove the conditional formatting, it all runs fine. Any suggestions?

Not finding an answer? Try a Google search.