Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all. How can I have VBA clear the contents of the cells in the
LAST ROW in columns A,C,F, and K? The last row will vary, so VBA needs to determine which row is the last. The columns will remain static. Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim lastrow As Long lastrow = Range("A" & Rows.Count).End(xlUp).Row Range("A" & lastrow).ClearContents Range("C" & lastrow).ClearContents Range("F" & lastrow).ClearContents Range("K" & lastrow).ClearContents End Sub "Steve" wrote: Hi all. How can I have VBA clear the contents of the cells in the LAST ROW in columns A,C,F, and K? The last row will vary, so VBA needs to determine which row is the last. The columns will remain static. Thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try code like the following:
Sub AAA() Dim LastCell As Range Dim WS As Worksheet Dim N As Long Dim Cols As Variant Cols = Array("A", "C", "F", "K") Set WS = ActiveSheet With WS For N = LBound(Cols) To UBound(Cols) Set LastCell = .Cells(.Rows.Count, Cols(N)).End(xlUp) LastCell.Delete shift:=xlUp Next N End With End Sub This deletes the last value in each of the columns. It supports the case when the columns have different lengths. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2009 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Mon, 16 Mar 2009 14:21:00 -0700 (PDT), Steve wrote: Hi all. How can I have VBA clear the contents of the cells in the LAST ROW in columns A,C,F, and K? The last row will vary, so VBA needs to determine which row is the last. The columns will remain static. Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to clear contents of certain cells | Excel Discussion (Misc queries) | |||
Clear contents of cells if a condition is met | Excel Worksheet Functions | |||
Clear Contents Of Cells Where Value = 0 | Excel Worksheet Functions | |||
Is there a formula to clear the contents of a specific cell? | Excel Worksheet Functions | |||
Clear Contents - NonBold cells | Excel Discussion (Misc queries) |