Need Adjustments for Macro

rwmill9716

Active Member
Joined
May 20, 2006
Messages
493
Office Version
  1. 2013
Platform
  1. Windows
This macro reads Cells BY6 and BZ6 which are the code numbers found in Row 4. It then copies those columns into Cols BY and BZ starting at row 8.

My problem is that the data set has empty cells, and the macro is just copying to the first empty cell (the remaining data in Cols BY and BZ are data left from the last run). I need the macro to copy 500 Rows and not determine the range of a particular column by sensing the first empty cell.

Thanks for your help.

Code:
Sub Graph1()
Dim Found As Range

Set Found = Sheets("Graph").Rows(4).Find(what:=Sheets("Graph").Range("bz6").Value, LookIn:=xlValues, lookat:=xlWhole)
If Found Is Nothing Then Exit Sub

With Sheets("Graph")
    .Range(Found, Found.End(xlDown)).Copy Destination:=Sheets("Graph").Range("Bz8")
End With

Set Found = Sheets("Graph").Rows(4).Find(what:=Sheets("Graph").Range("bY6").Value, LookIn:=xlValues, lookat:=xlWhole)
If Found Is Nothing Then Exit Sub

With Sheets("Graph")
    .Range(Found, Found.End(xlDown)).Copy Destination:=Sheets("Graph").Range("BY8")
End With


End Sub






Excel 2003
BJBKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZCACB
2Catalyst Conc., %Caustic/Cat. RatioCat Conc
3ctl g0.424881
4606162636465
5Catalyst Conc., %Caustic/Cat. RatioCat ConcXY54.7433399.63659
632.752350.0065295.866621Code6162
732.144850.006465121.08722414CHMD.AMCAMC in CHMD1Correlation0.651829
831.838440.0073414CHMD.ACNACNin CHMD26162
932.105570.0074414CHMD.ADNADN in CHMD3Caustic/Cat. RatioCat ConcYX
1032.37270.0075414CHMD.BHMTBHMT in CHMD410.0065295.8666239.7178514.93756
1133.113910.00702496.280866414CHMD.CATCAT in CHMD520.006465121.087240.8278910.95147
1232.639830.0077414CHMD.DAMPDAMP in CHMD630.00741.8064341.8064310.24193
1332.906960.0078414CHMD.DCHDCH in CHMD740.00742.6376842.6376810.4913
1433.174090.0079414CHMD.H2OH2O in CHMD850.00743.4689243.4689210.74068
1533.441220.00710414CHMD.HMDHMD in CHMD960.00702444.1672644.16726
1633.708350.007142.321811414CHMD.HMIHMI in CHMD1070.00744.3001744.3001710.99005
1733.975480.007106.371212414CHMD.PACNPACN in CHMD1180.00745.1314245.1314211.23943
Graph
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Some of the columns were cut off so I repost the data.


Excel 2003
BKBLBMBNBOBPBQBRBSBTBUBVBWBXBYBZ
2Caustic/Cat. RatioCat Conc
3
46162636465
5Caustic/Cat. RatioCat ConcXY
60.0065295.866621Code6162
70.006465121.08722414CHMD.AMCAMC in CHMD1
80.0073414CHMD.ACNACNin CHMD26162
90.0074414CHMD.ADNADN in CHMD3Caustic/Cat. RatioCat Conc
100.0075414CHMD.BHMTBHMT in CHMD410.0065295.86662
110.00702496.280866414CHMD.CATCAT in CHMD520.006465121.0872
120.0077414CHMD.DAMPDAMP in CHMD630.00741.80643
130.0078414CHMD.DCHDCH in CHMD740.00742.63768
140.0079414CHMD.H2OH2O in CHMD850.00743.46892
150.00710414CHMD.HMDHMD in CHMD960.00702444.16726
Graph
 
Upvote 0
Try this in a copy of your workbook.

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> Graph1()<br>  <SPAN style="color:#00007F">Dim</SPAN> Found <SPAN style="color:#00007F">As</SPAN> Range<br>  <br>  <SPAN style="color:#00007F">With</SPAN> Sheets("Graph")<br>    <SPAN style="color:#00007F">Set</SPAN> Found = .Rows(4).Find(what:=.Range("BZ6").Value, LookIn:=xlValues, lookat:=xlWhole)<br>    <SPAN style="color:#00007F">If</SPAN> Found <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>    <br>    .Range(Found, .Cells(.Rows.Count, Found.Column).End(xlUp)).Copy Destination:=.Range("BZ8")<br>    <br>    <SPAN style="color:#00007F">Set</SPAN> Found = .Rows(4).Find(what:=.Range("BY6").Value, LookIn:=xlValues, lookat:=xlWhole)<br>    <SPAN style="color:#00007F">If</SPAN> Found <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>    <br>    .Range(Found, .Cells(.Rows.Count, Found.Column).End(xlUp)).Copy Destination:=.Range("BY8")<br>  <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>


The logic in your code (& mine) is that if BZ6 is not found in row 4, then we don't even bother to look for BY6 in row 4.
Is that what you intended?
 
Last edited:
Upvote 0
Thank you so much, Peter_SSs, that is indeed what I intended and this works link a charm. It enables me to quickly graph XY relationships by supplying the code numbers for hundreds of data. I have another macro that develops all their pairwise correlation functions so this lets me visualize those that are related.

ric miller
 
Upvote 0

Forum statistics

Threads
1,214,407
Messages
6,119,332
Members
448,888
Latest member
Arle8907

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