Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Something for you to study...
Assuming I made no mistakes in transcribing your code, the following (heavily commented code) can replace all the code you posted in your message... Sub Limits() Dim X As Long Dim Mix_Size As Long Dim RowNums(1 To 20) As Long Dim ColNums(1 To 20) As Long Dim StartSheetNum As String Dim EndSheetNum As String Dim GraphCell As String Dim GraphSheets() As String Dim ColLetters() As String Sheets("Data worksheet").Unprotect "1dickson" ' The graph sheets are assumed to be the same for all cases, so ' we define them outside of the loop for reference inside the loop GraphSheets = Split("9_5mm,25mm chart,3_4 in chart,1_2 in chart," & _ "#200_chart,#8_chart,#4_chart,dust_ac," & _ "vfa_chart,vma_chart,vtm_chart,ac_chart," & _ "gmm_chart,gse_chart,rice_chart", ",") Mix_Size = Range("Mix_Size").Value Select Case Mix_Size Case 1 '4052 With Sheets("JMF Changes") ' The row and column numbers are "coordinated", that is, ' the first row and column numbers are used together in ' the "Data worksheet" Cells command; same for the second ' row and column numbers, and so on through the 20th of each RowNums = Array(8, 32, 31, 30, 29, 28, 27, 26, 25, 24, _ 23, 22, 21, 20, 99, 99, 99, 99, 99, 65) ColNums = Array(3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, _ 7, 7, 7, 42, 39, 40, 41, 43, 3) ' The column numbers used in the Range command below (from ' the "JMF Changes" sheet) are also coordinated, from 1 to ' 20, to match up with their row and column numbers for the ' above Cell command call ColLetters = Split("E I J V K L M N O P Q R S T X Y Z AA W D") ' The sheet number for the Range command seems to always ' be 500 for this Case block EndSheetNum = "500" ' Assign the 20 values from the "JMF Changes" Ranges ' to the "Data worksheet" Cells For X = 0 To 19 Sheets("Data worksheet").Cells(RowNums(X), ColNums(X)) = _ .Range(ColLetter(X) & EndSheetNum) Next ' The "JMF Changes" Ranges for the graphs (sheet names ' assigned prior to the start of the For-Next loop) seem ' to always start at 11 and end at 500 for this Case block ' (Note: The 500 was assigned earlier in this Case block) StartSheetNum = "11" GraphCell = "C16" ' The Column letters for the Graphs are coordinated with ' the graph sheet names; that is, Column M goes with graph ' sheet "9_5mm", Column V goes with graph sheet "25mm chart" ' and so on. (Note: We are reusing the ColLetters array) ColLetters = Split("M V K L T O N A H G F E U W X") '***********Populate Graph***************** For X = 0 To 15 Sheets(GraphSheets(X)).Range(GraphCell).Value = _ .Range(ColLetters(X) & StartSheetNum & ":" & _ ColLetters(X) & EndSheetNum).Value Next End With ' The rest of your case should be able to be set up similarly Case 2 '...... '...... End Select End Sub Rick "Eric" wrote in message ... I am running a select case statement but have 28 different cases. Each case has 50 copy pastes. When I run this macro I get an error "Procedure too Large" , how can I stop this? Here is a copy of my first case (there needs to be 27 more after this one) sub limits() Dim Mix_Size As Integer Mix_Size = Range("Mix_Size").Value Sheets("Data worksheet").Select Sheets("data worksheet").unprotect "1dickson" Dim numone As Double Dim numtwo As Double Dim numthree As Double Dim numfour As Double Dim numfive As Double Dim numsix As Double Dim numseven As Double Dim numeight As Double Dim numnine As Double Dim numten As Double Dim numeleven As Double Dim numtwelve As Double Dim numthirteen As Double Dim numfourteen As Double Dim numfifteen As Double Dim numsixteen As Double Dim numseventeen As Double Dim numeighteen As Double Dim numninteen As Double Dim numtwenty As Double Select Case Mix_Size Case 1 '4052 numone = Sheets("jmf changes").Range("E500") numtwo = Sheets("jmf changes").Range("I500") numthree = Sheets("jmf changes").Range("J500") numfour = Sheets("jmf changes").Range("V500") numfive = Sheets("jmf changes").Range("K500") numsix = Sheets("jmf changes").Range("L500") numseven = Sheets("jmf changes").Range("M500") numeight = Sheets("jmf changes").Range("N500") numnine = Sheets("jmf changes").Range("O500") numten = Sheets("jmf changes").Range("P500") numeleven = Sheets("jmf changes").Range("Q500") numtwelve = Sheets("jmf changes").Range("R500") numthirteen = Sheets("jmf changes").Range("S500") numfourteen = Sheets("jmf changes").Range("T500") numfifteen = Sheets("jmf changes").Range("X500") numsixteen = Sheets("jmf changes").Range("Y500") numseventeen = Sheets("jmf changes").Range("Z500") numeighteen = Sheets("jmf changes").Range("AA500") numnineteen = Sheets("jmf changes").Range("W500") numtwenty = Sheets("jmf changes").Range("D500") Sheets("Data worksheet").Cells(8, 3) = numone Sheets("data worksheet").Cells(32, 7) = numtwo Sheets("Data Worksheet").Cells(31, 7) = numthree Sheets("Data Worksheet").Cells(30, 7) = numfour Sheets("Data Worksheet").Cells(29, 7) = numfive Sheets("Data Worksheet").Cells(28, 7) = numsix Sheets("Data Worksheet").Cells(27, 7) = numseven Sheets("Data Worksheet").Cells(26, 7) = numeight Sheets("Data Worksheet").Cells(25, 7) = numnine Sheets("Data Worksheet").Cells(24, 7) = numten Sheets("Data Worksheet").Cells(23, 7) = numeleven Sheets("Data Worksheet").Cells(22, 7) = numtwelve Sheets("Data Worksheet").Cells(21, 7) = numthirteen Sheets("Data Worksheet").Cells(20, 7) = numfourteen Sheets("data worksheet").Cells(99, 42) = numfifteen Sheets("Data Worksheet").Cells(99, 39) = numsixteen Sheets("Data Worksheet").Cells(99, 40) = numseventeen Sheets("Data Worksheet").Cells(99, 41) = numeighteen Sheets("Data Worksheet").Cells(99, 43) = numnineteen Sheets("Data Worksheet").Cells(65, 3) = numtwenty '***********Populate Graph***************** Sheets("JMF Changes").Select Range("M11:M500").Select Application.CutCopyMode = False Selection.Copy Sheets("9_5mm").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("V11:V500").Select Application.CutCopyMode = False Selection.Copy Sheets("25mm chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("K11:K500").Select Application.CutCopyMode = False Selection.Copy Sheets("3_4 in Chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("L11:L500").Select Application.CutCopyMode = False Selection.Copy Sheets("1_2 in chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("T11:T500").Select Application.CutCopyMode = False Selection.Copy Sheets("#200_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("O11:O500").Select Application.CutCopyMode = False Selection.Copy Sheets("#8_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("N11:N500").Select Application.CutCopyMode = False Selection.Copy Sheets("#4_chart (2)").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("AD11:AD500").Select Application.CutCopyMode = False Selection.Copy Sheets("dust_ac").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("H11:H500").Select Application.CutCopyMode = False Selection.Copy Sheets("vfa_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("G11:G500").Select Application.CutCopyMode = False Selection.Copy Sheets("vma_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("F11:F500").Select Application.CutCopyMode = False Selection.Copy Sheets("vtm_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("E11:E500").Select Application.CutCopyMode = False Selection.Copy Sheets("ac_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("U11:U500").Select Application.CutCopyMode = False Selection.Copy Sheets("gmm_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("W11:W500").Select Application.CutCopyMode = False Selection.Copy Sheets("gse_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Sheets("JMF Changes").Select Range("X11:X500").Select Application.CutCopyMode = False Selection.Copy Sheets("rice_chart").Select Range("C16").Select Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False Any help would be greatly appreciated. Thank you in advance.... Eric |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Procedure too large | Excel Programming | |||
Procedure Too Large | Excel Programming | |||
Procedure too large | Excel Programming | |||
Procedure too large | Excel Programming | |||
procedure too large | Excel Programming |