Home>
Software/Language
Software used: Access 2016
Language: VBA
WsObj.cells (3, 1), cells (5, j-1) .AutoFilter
In this line, the range is specified only with Cells, so a syntax error has occurred.
How should I specify the range?
Public Sub Format ()
Dim AppObj As Object 'Excel.Application object declaration
Dim WBObj As Object 'Excel.Workbook object declaration
Dim WsObj As Object 'Excel.WorkSheet object declaration
Dim Path, Exf As String
Dim i, j As Integer: i = 1: j = 1
'Specify Excel file path
Path = "Application.CurrentProject.Path \"
'* Notation when the Excel file is in the same folder as the Access file used
Exf = Dir (Path&"* .xlsx")
'
Do
'Runtime binding
Set AppObj = CreateObject ("Excel.Application")
'Open the workbook for editing
Set WBObj = AppObj.WorkBooks.Open (Exf)
'Set the worksheet to be edited
Set WsObj = WBObj.Worksheets (1)
AppObj.Visible = False 'Do not show Excel application
'Repeat process
Do
'Repeat process
Do
'Set the format for the text [Start abbreviation]
With WsObj.cells (i, j) .Font
'Change font
.Name = "MS P Gothic"
'Change text size
.Size = 16
'Bold text
.Bold = True
'Change the text color
.Color = RGB (0, 0, 0)
'Omitted description End
End With
'If current row is even
If j Mod 2 = 0 Then
'Change cell background color
WsObj.Range (cells (i, j)). Interior.Color = RGB (153, 204, 255)
'End branch processing
End If
'Move to the next column
i = i + 1
'Repeat until there is a blank cell in the current row
Loop Until WsObj.cells (i, j) = ""
'Add row count
j = j + 1
'Repeat until next row A column cell is empty
Loop Until WsObj.cells (1, j) = ""
'Set filters in the 3rd to 5th columns
'A syntax error will occur on this line.
WsObj.cells (3, 1), cells (5, j-1) .AutoFilter
'Save and close Excel
WBObj.Save 'Save the workbook
WBObj.Close 'Close workbook
AppObj.Quit
Exf = Dir ()
'Repeat until no more files
Loop Until Exf = ""
End Sub
-
Answer # 1
Related articles
- access vba docmd about range specification using export function
- convert excel vba cells to range
- i want to switch the vba specified range cells vertically and horizontally
- vba - access collective address acquisition and email transmission
- vba - how to display the data of the same number of months in access form like cell merging
- how to avoid the specification of rewriting data in vba cell formatting
- vba - how to write when changing the data range of a line graph
- vba - i want to display a specified form in the access subform
- vba - about cascading update of access field
- please tell me about the range specification of image processing using opencv
- access addition query vba to auto-near type field
- vba - i want to move only the bold cells to the a column when the bold cells and the ordinary cells are mixed in the b column
- vba - access dialog box
- access vba extract including date type
- [vba] image height specification based on cell height
- vba - how to insert a total row for each work date/content in access form
- [access] i want to change the link destination of the link table with vba
- display the result of access vba parameter query on subform
- python range specification and value retrieval
- vba - access form form record source
Related questions
- i want to access access files on sharepoint from excel vba on my local pc (directly without using onedrive)
- access&excelvba how to handle blank data
- vba - how to search in an access form like an excel autofilter
- vba - [database design] about table design when referencing/updating the access database using excel as an input screen
- vba - please teach me how to centrally manage customer lists
- vba - no error occurs in docmdtransferspreadsheet in the form of operating access from excel
- i want to use the export function (docmdtransferspreadsheet) of access from excel vba
- vba - how to launch an access file with a password from task scheduler
- excel vba end property cannot be used
- vba - i want to import the xlsx file in which the positional relationship between the item name and the contents of the data she
> WsObj.cells (3, 1), cells (5, j-1) .AutoFilter
↓
WsObj.Range (WsObj.Cells (3, 1), WsObj.Cells (5, j-1)). AutoFilter