PDA

View Full Version : Solved: Selection of columns and clearing values



alivenwell
10-10-2007, 04:34 AM
Hi, I'm a complete newbie to Vba, so hopefully someone can help me with this simple code that I completely don't understand why it doesn't work.



lastcell = Cells.Find("Sunday", , xlValues, xlPart, xlByRows, xlPrevious, False).Column 'finding the last sunday on the timetable
lastcell = lastcell + 1 ' setting the first 1st value column after that sunday
lastcol = GetLast(shtCCL, False) 'using a private functon "Getlast", finding the last column with data in the sheet
Columns(lastcell, lastcol).Select 'using the lastcell column number and lastcol column number, select the columns from lastcell to lastcol
Selection.ClearContents 'deleting the values in that selection
Range("A1").Select



Thanks

matthewspatrick
10-10-2007, 06:34 AM
Please use line breaks/continuators to make the code easier to read.

Try this:


'finding the last sunday on the timetable
lastcell = Cells.Find("Sunday", , xlValues, xlPart, xlByRows, _
xlPrevious, False).Column
' setting the first 1st value column after that sunday
lastcell = lastcell + 1
'using a private functon "Getlast", finding the last column
'with data in the sheet
lastcol = GetLast(shtCCL, False)
'using the lastcell column number and lastcol column
'number, select the columns from lastcell to lastcol
Range(Columns(lastcell), Columns(lastcol)).ClearContents
Range("A1").Select

alivenwell
10-10-2007, 08:43 AM
works THANKS!!!!!

lucas
10-10-2007, 08:49 AM
Please mark your thread solved using the thread tools at the top of the page