Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default VBA Loop Problem

replace this line with this one and give it a try


Sheets("CEU Database").Range("J3:J65536").Select


-----Original Message-----
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
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
do while loop problem April Excel Discussion (Misc queries) 4 October 18th 09 07:51 PM
Loop Problem Todd Huttenstine Excel Programming 10 April 12th 04 06:15 PM
For...Each Loop Problem SuperJas Excel Programming 4 April 2nd 04 05:01 AM
For..Next loop problem Dwaine Horton Excel Programming 1 February 18th 04 12:12 AM
loop problem joao Excel Programming 4 November 6th 03 02:01 PM


All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"