Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Offset and ActiveCell
Office03
Hey gang, Have tried to get some assistance in the Access group with limited success for formatting, but I need some VBA help in referencing Excel from Access. All code is in Access. I am looping through a recordset and writing data to an Excel template. The data is being written down-then-across from column to column. "A2" is always the starting point and I am using an offset to move to each column and then move downward to write data. I am having problems setting the reference to the new cell (activating the cell) in using Offset and then being able to write data to that cell and format it appropriately. Any help, clean-up, suggestions are appreciated! I've eliminated working code to shorten the post but have kept (and double-checked) all paired IF, WITH, etc., statements ....Working code before this, dim statements, etc. Set objWkbk = objExcel.workbooks.Open(stTemplate) x = 0 y = 1 ....working code... Set rs = db.OpenRecordset(sSQL) stCell = "A2" rs.MoveFirst With objWkbk .sheets("Sheet1").Select .sheets("Sheet1").Activate .sheets("Sheet1").Name = stSheetName irow = 2 icolumn = 1 Do While Not rs.EOF icolumn = icolumn + x CName = rs("CourtName") .....series of IF statements to set variables...... With .ActiveSheet ....ERROR on the following line. Msg: Object doesn't support this property or method .ActiveCell.Offset(0, icolumn).Activate With ActiveCell .Value = CName .HorizontalAlignment = xlcenter .Font.Bold = True End With CID = rs("CourtID") Do While CID = rs("CourtID") TID = rs("MatchTimeID") Do While TID = rs("MatchTimeID") ....write data here (once I get the above problem resolved).... Loop TID = -1 Loop End With CID = -1 x = x + 1 Loop End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If activecell.column = variable then activecell,offset (0,1) | Excel Discussion (Misc queries) | |||
ActiveCell Offset | Excel Programming | |||
Activecell Offset | Excel Programming | |||
ActiveCell.Offset w/ VBA | Excel Programming | |||
activecell offset | Excel Programming |