View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mark
 
Posts: n/a
Default Macro to add more lines

This will do the trick

Private Sub CommandButton1_Click()

Dim CurRow As Integer
Dim ColLtr(5) As String
Dim CurCol As Integer

ColLtr(0) = "B"
ColLtr(1) = "C"
ColLtr(2) = "D"
ColLtr(3) = "E"
ColLtr(4) = "F"
ColLtr(5) = "G"

Application.ScreenUpdating = False
For CurCol = 0 To UBound(ColLtr)

CurRow = 0
Debug.Print " The currently selected column is " & _
ColLtr(CurCol)
CurRow = CurRow + 1
Range(ColLtr(CurCol) & CurRow).Select
Do Until Selection = ""
Range(ColLtr(CurCol) & CurRow).Select
CurRow = CurRow + 1
Loop
Range(ColLtr(CurCol) & CurRow).Offset(-1, 0) = _
Range(ColLtr(CurCol) & CurRow).Offset(-2, 0)

Next CurCol
Application.ScreenUpdating = True

End Sub