Issues crossing sheets

ILoveCheese

New Member
Joined
Mar 27, 2008
Messages
27
The code I put together is suppose to:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
1. Cycle through a list of names (AH360:AH366) and apply them to the same set of formulas.<o:p></o:p>
2. All of formulas key off of a single cell (W385), this is where the names cycle to.<o:p></o:p>
3. The formulas generate totals based on the name. <o:p></o:p>
IE: Joe = 40 widgets (W2001:AD2001)<o:p></o:p>
4. The totals are then pulled and transfered to a "Totals" sheet and placed next to the appropriate person. (B6:B12)<o:p></o:p>
<o:p></o:p>
My code is doing all of this except that it is pasting the same data on the "Totals" sheet for every person.<o:p></o:p>
<o:p></o:p>
Sub LOOPTEST()<o:p></o:p>

Dim M As Integer, X As Integer
For M = 360 To 366
For X = 6 To 12<o:p></o:p>
Sheets("Plan Designs").Range("AH" & M).Copy Destination:=Range("W385")
Sheets("Plan Designs").Range("W2001:AD2001").Copy
Sheets("Totals").Range("B" & X).PasteSpecial xlValues<o:p></o:p>
Next X
Next M<o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
I got this to work with a simple version on the same sheet, but once I tried to cross over sheets I ran into this problem. I am stuck on trying to get each set of total data to copy and paste over before the next name generates a new set of data.<o:p></o:p>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Your code does not seem to be in line with your description of what you want to do.

Try stepping through the code via F8 to see what it is actually doing so as to establish where it needs amending.

Watch the cholestorol count !!
 
Upvote 0
I went back through it and ran some simple examples again. If I keep the integer the same it works. When I change the Integer so the result is in a new location the same thing happens.

So I am guessing this is my problem area.

Sheets("Totals").Range("B" & X).PasteSpecial xlValues

I'll see if I can pick it apart some more.
 
Upvote 0
I am still testing this without success. The first chunk of code works the way I want. The portion with the second integer produces inaccurate data. There is obviously something I do not understand about implementing multiple integers. If someone could help me out I would appreciate it. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
<o:p></o:p>
Sub LOOPTEST()<o:p></o:p>

Dim M As Integer, X As Integer
For M = 5 To 10
For X = 20 To 25<o:p></o:p>

<o:p></o:p>
Range("A" & M).Copy Destination:=Range("D15")
Range("I21")<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:eek:ffice:smarttags" /><st1:place w:st="on"><st1:PlaceName w:st="on">.Copy</st1:PlaceName>
<st1:PlaceType w:st="on">Range</st1:PlaceType></st1:place>("M" & M).PasteSpecial xlValues<o:p></o:p>


Range("A" & M).Copy Destination:=Range("D15")
Range("J21")<st1:place w:st="on"><st1:PlaceName w:st="on">.Copy</st1:PlaceName>
<st1:PlaceType w:st="on">Range</st1:PlaceType></st1:place>("N" & X).PasteSpecial xlValues<o:p></o:p>

<o:p></o:p>
Next X
Next M<o:p></o:p>

End Sub<o:p></o:p>
 
Upvote 0
I don't understand what you want to do.

Perhaps you could post a sample of your worksheet(s). Or perhaps someone else can help.
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

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