need sub to work in sequence

kl2190

New Member
Joined
Oct 28, 2010
Messages
15
i the need folowing sub to work in sequence because the second part of the sub relys on the on the 1st part to work correctly. any ideas :confused:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> New_Button_Click()<br><br>    LastRowSL = Worksheets("Saw List").UsedRange.Rows.Count<br>    <br>    <br>    <SPAN style="color:#00007F">If</SPAN> Range("A3").Value = "XO" <SPAN style="color:#00007F">Then</SPAN><br>    Worksheets("Formulas").Range("A2:A10").Copy _<br>    Destination:=Worksheets("Saw List").Range("B" & LastRowSL + 1)<br><br>    LastCell = Worksheets("Saw List").Cells(Rows.Count, "C").End(xlUp).Row<br>    Worksheets("Windows").Range("E2").Copy _<br>    Destination:=Worksheets("Saw List").Range("C" & LastCell + 1 & ":C" & LastRowSL)<br>    <br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>       <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
It already works in sequence, top to bottom. I think you mean you need some kind of test to check whether part 1 worked correctly. You probably need to add another IF statement to test this

Define "correctly" in this context, what is going wrong? i.e. what does any new logic test need to look for?

Also, when posting code to the forum, simply wrap code tags around it (see # button above message input box)
 
Upvote 0
by correctly i mean. example that the 1st part of the code copies 5 rows worth of info (some times more or less). the 2nd copies 1 cell worth of info but i need it to copy down to the last used row in column C. i hope that clear??
 
Upvote 0
thanks for the advise bout the # tags. i need it to recognise whats its pasted in the 1st section then the 2nd paste will come down to the last row.
 
Upvote 0
are you copying formulas or values?

You don't need to copy and paste values, you can simply tell Excel to make the destination range = source value

e.g.
Code:
Worksheets("Saw List").Range("C" & LastCell + 1 & ":C" & LastRowSL) = Worksheets("Windows").Range("E2").value

Similarly, you can use Formula or FormulaR1C1 instead of Value, to copy formulas either as they are, or relatively

From what I can see, you should be able to get this all working by understanding how ranges are declared and set, and then how you can set attributes to these ranges, such as Value or Formula. It's usually quicker and more accurate than copy/pasting all the time too

Hope this helps
 
Upvote 0
much appreciated. your help has got me going in a different direction. the right direction :biggrin:

peace
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top