i have th following code that runs for one of my tables... the thing is that i need to get the name of the table every time and loop the code. all the tables are listed in one table
so i have
RFGWORKING (it lists all my working tables)
the code for the one table is...
'Table RN00144GE3RFG
Set objRST = Application.CurrentDb.OpenRecordset("SELECT * FROM RN00144GE3RFG;")
Set xlSheet = xlWorkbook.Sheets(1)
With xlSheet
.Range("A2").CopyFromRecordset objRST
.Name = "JO-RN00144GE3"
i = 1
'create the column headings in cells
With objRST
For Each f In .Fields
With xlSheet
.Cells(1, i).Value = f.Name
i = i + 1
End With
Next
End With
'Change the font to bold for the header row
xlSheet.Columns.AutoFit
xlSheet.Range(xlSheet.Cells(1, 1), _
xlSheet.Cells(1, objRST.Fields.Count)).Font.Bold = True
Sheets("JO-RN00144GE3").Select
With .Range("A1:T1").Interior
.ColorIndex = 15
.Pattern = xlSolid
lngRows = Range("a2").CurrentRegion.Rows.Count
lngCols = Range("a2").CurrentRegion.Columns.Count
Cells(lngRows + 3, lngCols - 3).Formula = "=SUM(Q1:Q" & lngRows & ")"
Cells(lngRows + 3, lngCols - 4).Formula = "=SUM(Q1:Q" & lngRows & ")"
'Add /fp to debit
ActiveWindow.SmallScroll ToRight:=3
Columns("Q:Q").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0"
Selection.Replace What:="0", Replacement:="\fp", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Selection.AutoFilter
'Remove the 0 values
Columns("P
").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0"
Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Selection.AutoFilter
Columns("P:Q").Select
Selection.NumberFormat = "#,##0.000"
End With
End With
Any suggestions how to make it work for all?
so i have
RFGWORKING (it lists all my working tables)
the code for the one table is...
'Table RN00144GE3RFG
Set objRST = Application.CurrentDb.OpenRecordset("SELECT * FROM RN00144GE3RFG;")
Set xlSheet = xlWorkbook.Sheets(1)
With xlSheet
.Range("A2").CopyFromRecordset objRST
.Name = "JO-RN00144GE3"
i = 1
'create the column headings in cells
With objRST
For Each f In .Fields
With xlSheet
.Cells(1, i).Value = f.Name
i = i + 1
End With
Next
End With
'Change the font to bold for the header row
xlSheet.Columns.AutoFit
xlSheet.Range(xlSheet.Cells(1, 1), _
xlSheet.Cells(1, objRST.Fields.Count)).Font.Bold = True
Sheets("JO-RN00144GE3").Select
With .Range("A1:T1").Interior
.ColorIndex = 15
.Pattern = xlSolid
lngRows = Range("a2").CurrentRegion.Rows.Count
lngCols = Range("a2").CurrentRegion.Columns.Count
Cells(lngRows + 3, lngCols - 3).Formula = "=SUM(Q1:Q" & lngRows & ")"
Cells(lngRows + 3, lngCols - 4).Formula = "=SUM(Q1:Q" & lngRows & ")"
'Add /fp to debit
ActiveWindow.SmallScroll ToRight:=3
Columns("Q:Q").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0"
Selection.Replace What:="0", Replacement:="\fp", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Selection.AutoFilter
'Remove the 0 values
Columns("P

Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="0"
Selection.Replace What:="0", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=True
Selection.AutoFilter
Columns("P:Q").Select
Selection.NumberFormat = "#,##0.000"
End With
End With
Any suggestions how to make it work for all?