Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with some excel VB code to move from row to row 1

Status
Not open for further replies.

Forrest77

Technical User
Apr 5, 2006
31
0
0
US
First of all thanks for taking a look because this is way beyond my scope.
I have about 50+ rows of excel data of a length from A thru F. I want to copy each row one at a time to say r30 to w30, perform some if/then statements that are working for me, and then print a sheet2 which has a lot of text boxes and labels that reference to r30 to w30 that create a label. After it has printed the sheet2 with the copied data from r30 to w30, I want to clear the data form r30 to w30 and start over but have the selected cells be the next row down that has data past the orginal 1st row. So if I started with my data rows at sheet1.Range("A12:F12"), how do I get a code that will move me to the next row that has data in it. I can do the code for the copy, paste, clear cells, print sheet but cannot figure a way to have it move down the rows or loop. I could write code for each row but each time I open the Sheet1, the rows can be anywhere from 2 rows of data to 200 rows of data and I need a seperate printout for each row...
Again thanks for looking and I am sorry for the long drawn out and probably too wordy explaination. You people are wonderful for providing all the help you do. Again
Thanks for your time.
Todd
 




Hi,

You need to do some reading to get up to speed on the Excel Object Model.
Code:
dim r as range
for each r in range([A12], [A12].end(xldown))
  range(r, r.offset(0,5)).copy [r30]
  'now do the other stuff
next


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks Skip, You are definitely right about needing to read and get up to speed. Do you have any suggestions as to reading material for those quite weak in this. I have not had any formal training at all.
And Thanks for the code. I will try it tomorrow and let you know how it works. I appreciate your time and patience.
Back to you later,
Todd
 
Thanks Again Skip, The code is doing close to what I want. I just need to adjust some parameters and code that I am using with what you provided. It is really slick. I will start spending some reading time at those sites. Again, I Thank You. In fact about 20 people thank you for making our job a little easier.
Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top