Thanks so much. The code associated with the form was bogus. Not sure how it got there. Any suggestions or shortcuts for my workbook are appreciated.
Thanks so much. The code associated with the form was bogus. Not sure how it got there. Any suggestions or shortcuts for my workbook are appreciated.
![]()
Private Sub UserForm_Initialize() Desc1.Caption = ActiveSheet.Range("A30").Value Desc2.Caption = ActiveSheet.Range("A31").Value Desc3.Caption = ActiveSheet.Range("A32").Value Desc4.Caption = ActiveSheet.Range("A33").Value Desc5.Caption = ActiveSheet.Range("A34").Value Desc6.Caption = ActiveSheet.Range("A35").Value Desc7.Caption = ActiveSheet.Range("A36").Value Desc8.Caption = ActiveSheet.Range("A37").Value Desc9.Caption = ActiveSheet.Range("A38").Value Desc10.Caption = ActiveSheet.Range("A39").Value Desc11.Caption = ActiveSheet.Range("A40").Value Desc12.Caption = ActiveSheet.Range("A41").Value Desc13.Caption = ActiveSheet.Range("A42").Value Desc14.Caption = ActiveSheet.Range("A43").Value End Sub
Ben Van Johnson
Okay here are just a few tips which may help.
First, declare all variables and to ensure this happens enable Option Explicit.
Go to the VBE >> Alt + F11 >> Options >> Editor Tab >> Require Variable Declaration.
Second, a little code clean up is necessary. You have a lot in there and it may take some considerable effort, but in the end the your spreadsheet will thank you.
The basic premise; usually there is no need to select an object to work with it in VBA so you can drop most of the Select/Selection, it just slows down the overall speed. As you are recording code, whatever you do is recorded, just like when you scroll the mouse (ActiveWindow.SmallScroll Down:=-6). This part is not necessary and is one of the culprits to slowing overall performance.
Some more reading Beyond the Macro Recorder.
Now, for an example of how you can clean up what you have. If you add a blank sheet to your workbook and title that blank sheet Sheet1 you can run this test code. Open up the VBE and place this code in a module and then place your cursor on the routine. Using F8 you can step through the code and watch it work. This means, if you have a dual monitor setup you can step through the code as you watch it play out on the Excel worksheet.
Here’s a webpage which can add to speeding up code .
Last thing I'll say is indenting code is a very good habit. Not only does it make the code easier for you to follow, but when you ask somebody else to look at your code it will make it easier for them too. One of the links below is for identing code.
Also for the passwords…![]()
Option Explicit Sub Testing() With Application .ScreenUpdating = False End With Dim TestingRange As Range Set TestingRange = Sheets("Sheet1").Range("A1:C10") With TestingRange .FormulaR1C1 = "=+0" .Borders(xlEdgeLeft).LineStyle = xlThick .Borders(xlEdgeTop).LineStyle = xlThick .Borders(xlEdgeBottom).LineStyle = xlThick .Borders(xlEdgeRight).LineStyle = xlThick .Copy .Range("F1").PasteSpecial Paste:=xlPasteValues With Application .ScreenUpdating = True .CutCopyMode = False .Goto [D12] End With .Clear End With End Sub
![]()
With Sheets("Whatever") .Unprotect "PasswordGoesHere" '' Your code .Protect "PasswordGoesHere" End With
http://www.excelforum.com/2078299-post14.html
http://www.mrexcel.com/forum/showthread.php?t=339643
http://www.mrexcel.com/forum/showthread.php?t=352116
http://www.mrexcel.com/forum/showthread.php?t=517549
HTH
Regards, Jeff
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks