View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
SunTzuComm SunTzuComm is offline
external usenet poster
 
Posts: 30
Default macro with variable rows

Annelie,

I'm can't tell exactly what type of processing your macro does, but here is the
basic principle of handling an unknown number of rows or columns.

If you select -- that is, highlight -- all the data in your worksheet, the
macro can process all the selected rows and columns this way.

' List the contents of all cells in a selected range:
Dim vntCol As Variant
Dim vntRow As Variant

For Each vntRow In Selection.Rows
For Each vntCol In Selection.Columns
With ActiveSheet.Cells(vntRow.Row, vntCol.Column)
Debug.Print .Value
End With
Next vntCol
Next vntRow

I hope this helps,
Wes