Posts by jproffer
-
-
Re: macro button links
Another thing you might think about is forcing the SaveAs DialogBox in a Workbook_Open event. Naturally they could just cancel it, unless you code it to keep bringing up the Dialogbox until they saved it AS something locally. (and before you ask
......I wouldn't have the slightest idea HOW to do that, but knowing the power of VBA, I would say it's probably possible)
-
Re: macro button links
Not really. I don't email a lot of WBs, and when I do it's just for THAT person, so they generally just save it.
Another thing you could do is put the WB on Google Docs, then they are forced (I think) to download it before changing it...then they can upload again, and send the next person a quick "your turn" email without any attachments.
Of course that would require that they don't "jump the gun" so to speak. If they did, they would be changing what would, in a few minutes, be an outdated version. It would be risky, to say the least....depends on the people.
-
Re: macro button links
Let them not get paid a few times because of lost/corrupted data and they will see the light :saychees:
But you could put a pop-up message box each time the file is opened, telling (warning) them of possible lost data if they didn't first SAVE the file to their local drive.
-
Re: extract numbers with decimals from alphanumerics
Try this as a UDF:
CodeFunction CatchLastNumbers(MyRng As String) Dim MyRev As String Dim Start As Long MyRev = StrReverse(MyRng) Start = Len(MyRev) - WorksheetFunction.Find(" ", MyRev) + 2 CatchLastNumbers = Mid(MyRng, Start, 9999) End Function
Formula syntax: =CatchLastNumbers(A1)
-
Re: Worksheet change event running on row below target
Looks like you were offsetting before you copied...not sure, but anyhow try this as your macro (normal...not sheet code)
Code
Display MoreSub myMacro() Dim myInput As Integer Dim myString As String On Error Resume Next myInput = ActiveCell.Value If IsNumeric(myInput) Then myString = _ "=VLOOKUP(CONCATENATE(RC[-2],"" "",RC[-1]),Database!R3C1:R100C2,2,FALSE)&TEXT(" & myInput & ",""0000"")" ActiveCell.Value = myString ActiveCell.Value = ActiveCell.Value Else End If End Sub
-
Re: Macro wont stop running once if-then-else statment is true
Just saw your last. Glad it's working.
-
Re: Macro wont stop running once if-then-else statment is true
It should break.
sets a variable to the value of C3
Just as it sounds, it tells it to go on and skip the error (if there is no sheet with that name)
Attempts to activate a sheet called (whatever is in C3)
"Err" is the count of errors. So if Err = 0 then it DID activate the sheet with that name....so the msgbox...
pops up
and the code stops.
End If
kills the error handler from above, and resumes normal runtime...will break on error.Is that not what you wanted? If you don't exit after the message box, it will add a sheet and try to name it to C3 and will error out because there is already a sheet with that name.
-
Re: Macro wont stop running once if-then-else statment is true
Code
Display MoreSub Create_Work_Order() 'Turn Off Screen Update Application.ScreenUpdating = False 'This is What I Added If Range("G5").Value = "1" Then MsgBox ("Please Enter Components Required (Body and Neck, Body, or Neck)") Exit Sub End If 'Copy 'Order Builder' Sheet Cells.Copy testname = Range("C3").Value On Error Resume Next Sheets(testname).Activate If Err = 0 Then MsgBox "A sheet with that name already exists." Exit Sub End If On Error GoTo 0 'Add New Sheet Worksheets.Add(After:=Worksheets("Order Builder")).Name = Range("C3").Value 'Paste All ActiveSheet.Paste 'Delete Button and Pricing Info ActiveSheet.Shapes("Button 19").Delete Select Case Range("G5").Value Case 2 Columns("H:H").EntireColumn.Hidden = True Columns("O:O").EntireColumn.Hidden = True Range("I25:L26").ClearContents Range("A1:C1").Value = "Tele Work Order" Case 3 Columns("H:H").EntireColumn.Hidden = True Columns("I:R").Delete Shift:=xlToLeft ActiveSheet.Shapes.Range(Array("Drop Down 11", "Drop Down 12", "Drop Down 13", _ "Drop Down 14", "Drop Down 15", "Drop Down 16", "Drop Down 17", "Drop Down 18")).Delete Range("A1:C1").Value = "Tele Work Order" Case 4 Columns("K:K").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ActiveSheet.Shapes.Range(Array("Drop Down 1", "Drop Down 2", "Drop Down 3", _ "Drop Down 4", "Drop Down 5", "Drop Down 6", "Drop Down 7", "Drop Down 8", _ "Drop Down 9", "Drop Down 10")).Delete Range("B5:I27").Delete Shift:=xlToLeft Columns("H:H").ClearContents Columns("C:C").ColumnWidth = 6.57 Range("B23:I27").ClearContents Range("A1:C1").Value = "Tele Work Order" Case Else MsgBox "Error Has Occured. Please Check Your Component Selection And Try Again" End Select 'Turn On Screen Updating Application.ScreenUpdating = True End Sub
Try this one. It will try to activate a sheet named (whatever is in C3), if it does (and there is NO error) then Err=0 and it will trigger the messagebox and exit. After that, it kills the error handler and resumes as normal.
One tip though...you really should qualify the range("C3")...as in, what sheet is it on?
Sheets("name").Range("C3").Value
-
Re: Macro wont stop running once if-then-else statment is true
Certainly not useless...and not horribly sloppy either.
Just can be better is all. That's as good a way to learn as any. The recorder does have limits though... making loops is the first that comes to mind...there are many other things it can't do.
-
Re: Macro wont stop running once if-then-else statment is true
Try this. I just cleaned up a bit and changed the IF statement to exit after the message box. All the selecting is unnecessary. If you record something, and see "select" at the end of one line, and "Selection" at the beginning of the next, you can combine them.
Also the "FormulaR1C1" isn't necessary IMO (some disagree), but even if you really are putting a formula in a cell, .Value will do that.
At any rate, here ya go
Code
Display MoreSub Create_Work_Order() 'Turn Off Screen Update Application.ScreenUpdating = False 'This is What I Added If Range("G5").Value = "1" Then MsgBox ("Please Enter Components Required (Body and Neck, Body, or Neck)") Exit Sub End If 'Copy 'Order Builder' Sheet Cells.Copy 'Add New Sheet Worksheets.Add(After:=Worksheets("Order Builder")).Name = Range("C3").Value 'Paste All ActiveSheet.Paste 'Delete Button and Pricing Info ActiveSheet.Shapes("Button 19").Delete Select Case Range("G5").Value Case 2 Columns("H:H").EntireColumn.Hidden = True Columns("O:O").EntireColumn.Hidden = True Range("I25:L26").ClearContents Range("A1:C1").Value = "Tele Work Order" Case 3 Columns("H:H").EntireColumn.Hidden = True Columns("I:R").Delete Shift:=xlToLeft ActiveSheet.Shapes.Range(Array("Drop Down 11", "Drop Down 12", "Drop Down 13", _ "Drop Down 14", "Drop Down 15", "Drop Down 16", "Drop Down 17", "Drop Down 18")).Delete Range("A1:C1").Value = "Tele Work Order" Case 4 Columns("K:K").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove ActiveSheet.Shapes.Range(Array("Drop Down 1", "Drop Down 2", "Drop Down 3", _ "Drop Down 4", "Drop Down 5", "Drop Down 6", "Drop Down 7", "Drop Down 8", _ "Drop Down 9", "Drop Down 10")).Delete Range("B5:I27").Delete Shift:=xlToLeft Columns("H:H").ClearContents Columns("C:C").ColumnWidth = 6.57 Range("B23:I27").ClearContents Range("A1:C1").Value = "Tele Work Order" Case Else MsgBox "Error Has Occured. Please Check Your Component Selection And Try Again" End Select 'Turn On Screen Updating Application.ScreenUpdating = True End Sub
-
Re: Make it VBA Short
That looks better (and more likely to work
) than mine.
-
Re: Make it VBA Short
I'm not sure this will work...because I'm not SURE you can use a loop variable in a workbook name, but you might try this out on a COPY of those 3 workbooks.
-
Re: Stumped! VBA Compile error in Function definition
Try removing "ByVal"
-
Re: lock cell
???
That message sounds like your workbook has some sheet code or workbook level code playing tricks with you.
Press Alt+F11
Press CTRL+R
Find the workbook you're talking about and expand it (with the + symbol to the left of the name).
Double click each worksheet and see if there is any code in any module.
Also double click on "ThisWorkbook" and check for code.
Code, if any, would be in the white area to the right after you double click the sheet/workbook
-
Re: Identify font style in an Excel sheet and generate a string
You can get the name of the style with this:
or
CodeSelect Case Range("A1").Font.FontStyle Case "Italic" Affil = "I" Case "Underline" Affil = "U" Case "Bold" Affil = "B" End Select
That would set your variable, but you would have to put in a "Case Else" for other styles or combinations of styles. Modify to whatever Letters vs. Styles you want in your variable.
I would suggest using the top code I listed to make sure you get the names right for various combinations. For instance, Bold/Underlined/Italic...Bold/Italic (but not underlined).....also there's the double underline.
So something like this would get you all those names as strings.
CodeSub GetFontStyle Dim FntStyl as String FntStyl = Range("A1").Font.FontStyle MsgBox FntStyl End Sub
EDIT: My mistake..."Underline" isn't a FontStyle, so there are only a few combinations. Anyhow, that should lead you in the right direction. Post back with any further questions. HTH
-
Re: Unhide All Individually Password-protected Sheets At Once
No problem...just thought maybe they could be moved above the post or something. Wasn't sure if that was a User CP setting or what. Thanks for clearing it up
-
Re: Unhide All Individually Password-protected Sheets At Once
I was hesitant on the code tags because sometimes they end up squeeed up on the left 1-2 inches of the screen. 8-)
...........soooooo, speaking of the ads, lol........is there a way to minimize/move the ads to a more convenient location?? (above the post would be fine, so long as the entire post wasn't restricted to the far left of the post window) -
-
Re: VBA Code to toggle off Workbook_SheetSelectionChange to create as add-in
CP: http://www.mrexcel.com/forum/s…8265&posted=1#post3068265
Please let us know if you're going to cross post.