View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
scrabtree23[_3_] scrabtree23[_3_] is offline
external usenet poster
 
Posts: 55
Default VBA Loop Problem

The code below loops through the J column then pastes the formula in K1 into
the K column. However, it also pastes the code other places and does some
other strange stuff. How can I improve this code?

' Pastes a good formula back in
If TypeName(Selection) < "Range" Then Exit Sub
On Error Resume Next
Sheets("CEU Database").Range("K1").Copy
' Check the cells with constants
Sheets("CEU Database").Columns("J3:J65536").Select
For Each Cell In Selection.SpecialCells(xlConstants, 23)
If Cell.Value < "" Then
Cell.Offset(0, 1).PasteSpecial Paste:=xlAll,
Operation:=xlNone, SkipBlanks:=False _
, Transpose:=False
End If
Next Cell
End Sub