Hi, try this: x = Cells(Rows.Count, "A").End(xlUp).Row y = Cells(x, Columns.Count).End(xlToLeft).Column Range("A1:" & Cells(x, y).Address).Select
Regards, Basole. 2014-04-04 11:17 GMT-03:00 Suyog Kulkarni <nashi...@gmail.com>: > Hello All, > > I made my first macro code. Kindly review. Now only problem remain is > instead of *Range("A1:I100"), I want excel to choose "last row & last > column" which contain text/value.* > > PL help. > > Regards, > Suyog > > " Below is my code" > > *Sub Format()* > > ' Format Macro > ' Keyboard Shortcut: Ctrl+q > ' This is range for Report Headings > Range("A1:I4").Select > Selection.ClearContents > With Selection > .HorizontalAlignment = xlCenter > .VerticalAlignment = xlCenter > End With > Selection.Merge > > ' This is range for Report Header Line > Range("A5:I5").Select > With Selection.Interior > .Color = 13434879 > Selection.Font.Bold = True > End With > > ' This is "total non blank area of any report. Or Cell range with > Text/value > * Range("A1:I100").Select* > With Selection.Borders > .LineStyle = xlContinuous > .Weight = xlThin > End With > Cells.Select > With Selection.Interior > Selection.Font.Name = "Calibri" > Selection.Font.Size = 11 > Selection.Font.ThemeFont = xlThemeFontMinor > End With > Cells.Select > Selection.Columns.AutoFit > With Selection > .VerticalAlignment = xlCenter > .HorizontalAlignment = xlCenter > .VerticalAlignment = xlCenter > End With > Range("A5").Select > ActiveWorkbook.Save > MsgBox "Formatting is done. Only add project details properly.", > vbOKOnly, "Made by Suyog Kulkarni" > *End Sub* > > > > > > On Friday, 4 April 2014 15:11:52 UTC+5:30, Suyog Kulkarni wrote: >> >> Hello All, >> >> Refer attached excel, I've tried to develop macro using recording for >> repetitive formatting. Now my problem is how can I assign range for all >> "Non-blank" cell. Because my current will work only upto "Row 13 & Column >> I". >> >> How can assign the code which can work till last row & column which >> contain text / value. Short cut for macro is Ctrl+q. I need this to improve >> productivity & you all can save my lot of time. I generate daily more than >> 50 reports of 100+ rows. This formatting takes time. >> >> Regards, >> Suyog >> > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It's > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros+unsubscr...@googlegroups.com. > To post to this group, send email to excel-macros@googlegroups.com. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It's =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.