Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am filling a range with data from Access queries where one of the queries
is a crosstab. The crosstab may produce from 1 to 6 columns and a variable number of rows. I know how many columns and rows the crosstab produces and I use those counts to help me point to the first column to be summed which I do with the following: rngStart01.Activate Set rng = appExcel.ActiveCell.Offset(rowOffset:=7 + intSummaryLineCount, columnOffset:=2) rng.FormulaR1C1 = "=SUM(R[" & (intSummaryLineCount * -1) & "]C:R[-1]C)" intSummaryLineCount is the number of rows and intConsCount is the number of columns being returned from the crosstab. I would like to copy the formula in the first cell pointed to across a calculated number of columns. The recorded macro on a sample sheet gave me the following: Range("C37").Select ' this is the cell pointed to by Set rng in above code Selection.AutoFill Destination:=Range("C37:G37"), Type:=xlFillDefault Range("C37:G37").Select ' G37 needs to be calculated using intConsCount Selection.NumberFormat = "$#,##0.00" The problems I have is 1) the correct syntax 2) how to use the column count within the Selection.and Range().Select I have the following variables set: Dim appExcel As Excel.Application Dim bks As Excel.Workbooks Dim rng As Excel.Range Dim rngStart01 As Excel.Range Dim wkb As Excel.Workbook Dim sht1 As Excel.Worksheet Set sht1 = appExcel.ActiveWorkbook.Sheets(1) Set rngStart01 = sht1.Range("A6") Set rng = appExcel.ActiveCell.Offset(rowOffset:=X, columnOffset:=X) to move around worksheet |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Look up value range in column and then count | Excel Discussion (Misc queries) | |||
Count Unique Values in 1 Column based on Date Range in another Column | Excel Worksheet Functions | |||
How do I count a range of dates in a column? | Excel Worksheet Functions | |||
Get column count used range from S to IV | Excel Programming | |||
How to count dates within a certain range in a column with mutiple date range entries | Excel Worksheet Functions |