ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   creating macros in excel (https://www.excelbanter.com/excel-programming/324881-creating-macros-excel.html)

LisaVan

creating macros in excel
 
I need help creating macros in excel. What I am trying to do is create a
loop (I think) to do the same thing in a column, say every 2 cells. For
example, I would like to take column C, and delete the contents in every
other cell. (delete C2, C4, C6, etc. for the entire column).
Any suggestions would be MOST helpful.
Thanks.
Lisa


Dave Peterson[_5_]

creating macros in excel
 
Maybe something like:

Option Explicit
Sub testme()

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
With Worksheets("sheet1")
FirstRow = 2
LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For iRow = 2 To LastRow Step 2
.Cells(iRow, "C").ClearContents
Next iRow
End With

End Sub

Did delete mean clearcontents?

LisaVan wrote:

I need help creating macros in excel. What I am trying to do is create a
loop (I think) to do the same thing in a column, say every 2 cells. For
example, I would like to take column C, and delete the contents in every
other cell. (delete C2, C4, C6, etc. for the entire column).
Any suggestions would be MOST helpful.
Thanks.
Lisa


--

Dave Peterson


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com