excel-2003

Which Excel VBA RegEx expression should I use to count decimal places?

爷,独闯天下 提交于 2019-12-24 17:25:50
问题 Q: Which Excel VBA RegEx expression should I use to count decimal places? Desired output This is a table with some example input strings and the desired output. INPUT DESIRED OUTPUT string max value unit decimal places -------------------------------------------------- 200A 200 A 0 110kV 110 kV 0 38,1MW 38,1 MW 1 38,1Mvar 38,1 Mvar 1 0-130°C 130 C 0 20-130°C 130 C 0 2000A 2000 A 0 10 kV 10 V 0 34,6MW 34,6 MW 1 34,6Mvar 34,6 Mvar 1 600A 600 A 0 114,3 MW 114,3 MW 1 114,3 Mvar 114,3 Mvar 1 2500A

Remove Cell Content & Shift Up Without Sort

こ雲淡風輕ζ 提交于 2019-12-24 12:34:25
问题 I wonder whether someone may be able to help me please. @Doug Clancy on this site offered some very much appreciated guidance and solution (shown below), which clears cell content and where necessary shifts the rows up to fill those that are blank. Sub DelRow() Dim RangeToClear As Range Dim msg As VbMsgBoxResult Sheets("Input").Protect "handsoff", UserInterfaceOnly:=True Application.EnableCancelKey = xlDisabled Application.EnableEvents = False msg = MsgBox("Are you sure you want to delete

How to determine if there are hidden columns when copying in Excel VBA

本秂侑毒 提交于 2019-12-24 10:48:09
问题 As the title explains, I have an Excel 2003 workbook and I'm copying a number of columns of one sheet to another in VBA. Unknown to me, someone has hidden a few columns on the source sheet and it has messed up how I process the cells in the destination sheet. How can I programmically determine: IF there are hidden columns WHICH columns are hidden? Thanks! JFV 回答1: For a Range , check the Range.Hidden property. The following snippet from MSDN is a good example of how to hide/unhide a row

Alternative to the Pictures collection in Excel 2010

ε祈祈猫儿з 提交于 2019-12-24 09:28:35
问题 Here is some code from an xls file. In Excel 2010 it doesn't work. I can't find the collection Pictures in the object explorer Private Sub Worksheet_Calculate() Dim oPic As Picture 'make them invisible For Each oPic In Me.Pictures If Left(oPic.Name, 2) = "jq" Then oPic.Visible = False End If Next end sub What would the equivalent 2010 code be? 回答1: Use this to loop through pictures in Excel Sub Sample() Dim shp As Shape For Each shp In ActiveSheet.Shapes If shp.Type = msoPicture Then Debug

XL2003: Changing ThisWorkbook.Windows().Visible property during Workbook_BeforeClose event prevents workbook from closing

情到浓时终转凉″ 提交于 2019-12-24 01:18:30
问题 As title. This is driving me mad and I can't find any reference to it anywhere else on the web. I have a VBA-laden workbook which is normally hidden through use of: ThisWorkbook.Windows(1).Visible = False However, when the workbook is closed I need it to revert to a default state whereby its window is visible and a "special" worksheet which instructs the user on enabling macros is shown. This is to provide guidance should the next user open the workbook with macros disabled. When the workbook

Password-protect the macros of a second workbook from a first using VBA

岁酱吖の 提交于 2019-12-24 00:14:00
问题 I have a workbook, which creates a second workbook (using ThisWorkbook.SaveCopyAs ) to present the data nicely to users. It relies on macros for part of the processing. However, I've been asked to make those macros inaccessible to users. They still need to run them, but to view/edit them should require a password. I can figure out how to do it using the GUI (VBA Editor -> right click VBAProject -> VBAProject Properties -> Protection, tick the box and enter a password), but I haven't found a

Deleting hidden name definitions with invalid names in Excel 2003

岁酱吖の 提交于 2019-12-22 10:53:19
问题 I am using this macro: http://support.microsoft.com/kb/119826 to try and clean up hidden names in my excel file. It works for most of the hidden names, but not for a few _123Graph names. I'm not sure where these names came from, but when I try to delete them I get a 1004 automation error. The knowledge base mentions that names with spaces may cause an error. Is there a way to delete these? 回答1: Excel 2007 and above resolves this issue... but a quick fix for Excel 2003 is: Go to the Tools Menu

Browse for a File from Excel VBA

南楼画角 提交于 2019-12-22 10:26:46
问题 How can I put up a "File Open" dialog from some VBA running in Excel? I'm using Excel 2003. 回答1: You want the Application.GetOpenFilename function. Copying from VBA Object Browser: Function GetOpenFilename([FileFilter], [FilterIndex], [Title], [ButtonText], [MultiSelect]) Member of Excel.Application 回答2: Add a reference to ComDLG32.OCX and then something like... Sub PromptForFile() Dim d As New MSComDlg.CommonDialog d.Filter = "xls" d.Filename = "*.xls" d.ShowOpen Excel.Workbooks.Open d

Timed Alarm in Excel VBA

萝らか妹 提交于 2019-12-22 08:37:03
问题 I made a calendar to track tasks and similar items in Excel 2003. What I need to be able to do is to set a timer via VBA. Something like this: run_in_x_secs ( timetowait, function to exec) Is there a way to do that in excel vba, or should I try and find an alarm to run via the command line and run that from VBA. How would you do it? 回答1: This should do the trick: Public Sub RunSubInXSeconds(secondsToWait As Long, nameOfFunction As String) Application.OnTime Now + secondsToWait/(24# * 60# * 60

Oracle query output in excel

耗尽温柔 提交于 2019-12-21 05:27:10
问题 I have an Oracle 10G database and I need to write a fairly straightforward query that joins two tables and selects some data. However, I'd like to export the result list to an excel, so end users can use this .xls document to see the results and filter by one of the fields (location) When I write the query, is there an easy way I can generate/ create an excel document that would hold these results as described above? The SQL doesn't need to run from within excel, but I guess that would be a