LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
steve hobden via OfficeKB.com
 
Posts: n/a
Default VB for excel, how do I loop through code

When trying to loop through code I get a compile error "loop without do".

The code should should start in cell A4 (sheet1), check if its value equals
that in t5 (sheet3). If it does, then it cuts A4:A14(sheet1) and pastes
into a7(sheet2).

It then does the same for B4, C4, D4 etc. and continues until it reaches an
empty cell. See code below

Sheets("sheet1").Select
Range("a4").Select
Do While Not IsEmpty(ActiveCell)
If ActiveCell = Sheets("sheet3").Range("t5") Then
ActiveCell.Select
Selection.Resize(1, 10).Select
Selection.Cut Destination:=Sheets("Sheet2").Range("a7")
Else
ActiveCell.Offset(1, 0).Select
Loop

Eventually I want to change the destination cell for pasting to be "the
first empty cell below A6" rather than "A7", but first things first.

Many thanks

Steve
 
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
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
VBA Newbie: Help with Do Loop code Carl Excel Discussion (Misc queries) 3 December 2nd 04 07:04 PM


All times are GMT +1. The time now is 01:40 AM.

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

About Us

"It's about Microsoft Excel"