i need a macro to Find last row with data and autofit, bold and center align all the cells in the row
i need a macro to Find last row with data and autofit, bold and center align all the cells in the row
Last edited by daillest319; 02-24-2012 at 11:32 AM.
daillest319,
Here's a simple code that may help you.
![]()
Sub Format_LastRow() Application.ScreenUpdating = False Dim lrow As Long lrow = Sheets("Sheet1").Range("A65536").End(xlUp).Row Range("A2:G" & lrow).Select With Selection .HorizontalAlignment = xlCenter End With With Selection.Font .FontStyle = "Bold" End With Columns("A:A").EntireColumn.AutoFit End Sub
Charles
There are other ways to do this, this is but 1 !
Be Sure you thank those who helped.
IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.
To find the last row of column A - you can use this code lineTo autofit -![]()
Dim lrow as long lrow = worksheets("Sheet1").range("A" & rows.count).end(xlup).row
To bold and center align, all you need to do is just record the action and you will get the code.![]()
Cells.entirecolumn.autofit
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Thanks i started using this code but cant seem to figure out how to make not only look just in column A but in all columns for the last row becuase some of the cells have empty data. For example the last row had A,B,C etc blank and the data starts at column G.
![]()
Dim lngLastRow As Long 'Range("A1").Select 'Range(Selection, Selection.End(xlDown)).Select Range("A1").End(xlDown).Select lngLastRow = ActiveCell.Row Rows(lngLastRow).Select Selection.Font.Bold = True Cells(lngLastRow, "A").Select
Hi,
Your code
Try![]()
Dim lngLastRow As Long 'Range("A1").Select 'Range(Selection, Selection.End(xlDown)).Select Range("A1").End(xlDown).Select lngLastRow = ActiveCell.Row Rows(lngLastRow).Select Selection.Font.Bold = True Cells(lngLastRow, "A").Select
But the code provided my myself and arlu1201 should do the job.![]()
Dim lngLastRow As Long 'Range("A1").Select 'Range(Selection, Selection.End(xlDown)).Select Range("A1").End(xlDown).Select lngLastRow = ActiveCell.Row range("A"& lngLasRow & ":G" & lngLasRow).select 'Rows(lngLastRow).Select Selection.Font.Bold = True 'Cells(lngLastRow, "A").Select
You can also use this -You can also specify the sheet instead of Activesheet.![]()
lrow = ActiveSheet.UsedRange.Rows.Count
thank you all for all yuor help
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks