excel-vba

excel vba sort sheet numerically

*爱你&永不变心* 提交于 2020-01-05 04:30:09
问题 I want to sort sheets in my excel file. I found this code which works. But the problem is that my sheet names are 1_abc, 2_adf, 3_dasf, 11_ad etc. This code puts 11_ad before 2_adf and 3_dasf. I would like to sort sheets based upon number before "_" (first underscore) in my sheet name. How could I do the same? ################################UPDATE1 I modified the code as below. But it is sorting in descending order :(. I want to sort in ascending order Option Explicit Sub SortWorksheets()

How to generate sheet for each specific values

核能气质少年 提交于 2020-01-05 04:17:09
问题 I include some code in my project and I have something I do not understand. My With loop doesn't works. My goal is to create new sheet from a specific cell B16 =House and other new sheet for each cells contains PRIVATE word. Example: When user click on button: - One new sheet created with title=Value of B16 just after my first sheet (name MyFirstSheet) - Some other sheets created for each cells values contains word PRIVATE, just after the previous sheet. So the result will be MyFirstSheet,

How to save ALL Excel files every say minute / 10 seconds?

非 Y 不嫁゛ 提交于 2020-01-05 04:02:12
问题 Question: How to save ALL Excel files every given time period - say every minute or every 10 seconds ? Related: here How to save Excel file every say minute? a way to save given file is described. But if I have many files it is a problem to process like that. Remark: In case if I need to save every minute - I can use Excel's autosave, but autosave is is in *.xlsb format which I have a problem reading by Python, also several files are created and it is not clear what file is saved in what

Show current time (EST)

天涯浪子 提交于 2020-01-05 03:55:13
问题 I created a UserForm that contains a textbox that will show the current time in EST. The only problem is, the time that's reflecting is of course the current time in our country so I want to convert it in EST, which is - 12:00 from our time. Private Sub UserForm_Initialize() If ActiveWorkbook.MultiUserEditing Then End If Application.ScreenUpdating = False Application.DisplayAlerts = False txtDate.Value = Format(Now, "mm/dd/yyyy") Application.ScreenUpdating = True Application.DisplayAlerts =

VBA to Create PivotTable, Type Mismatch? What Am I Doing Wrong?

瘦欲@ 提交于 2020-01-05 03:36:06
问题 Getting Type Mismatch on the line tabledestination:=("pivot!A3") I want to add a sheet and name it "Pivot" and create PivotTable on that sheet. Dim pt As PivotTable Dim Pcache As PivotCache Sheets.add.name = "Pivot" Sheets("DATA").Select Set Pcache = ActiveWorkbook.PivotCaches.Create(xlDatabase, Cells(1, 1).CurrentRegion) Set pt = ActiveSheet.PivotTables.Add(PivotCache, tabledestination:=("pivot!A3")) With pt PivotFields.Subtotals(1) = False .InGridDropZones = True .RowAxisLayout xlTabularRow

How do you specify a flagged item in Outlook with Excel VBA?

我与影子孤独终老i 提交于 2020-01-05 03:35:22
问题 I'm trying to get a count of how many emails are in my Outlook folders. The problem is that it is counting the "Flagged" items and I need the code to skip any item that is "Flagged". I've tried using the "olNoFlag" property on line 18 of the below code but it won't work. Can anyone help me with this? I'm so close! Sub LoopFoldersInNoctalkSW() Dim ns As Object Dim objFolder As Object Dim objSubfolder As Object Dim lngCounter As Long Dim olNoFlag As Object Set ns = GetObject("", "Outlook

How do you specify a flagged item in Outlook with Excel VBA?

拜拜、爱过 提交于 2020-01-05 03:34:32
问题 I'm trying to get a count of how many emails are in my Outlook folders. The problem is that it is counting the "Flagged" items and I need the code to skip any item that is "Flagged". I've tried using the "olNoFlag" property on line 18 of the below code but it won't work. Can anyone help me with this? I'm so close! Sub LoopFoldersInNoctalkSW() Dim ns As Object Dim objFolder As Object Dim objSubfolder As Object Dim lngCounter As Long Dim olNoFlag As Object Set ns = GetObject("", "Outlook

Get value from cell without transform in vba macros

て烟熏妆下的殇ゞ 提交于 2020-01-05 03:34:28
问题 I have an issue with vba macros. Cell contains value 941144280284022000000. But when try to get this value in macros, variable is equal 9.41144280284022E+20. Is it possible to get "real" value? Thanks. 回答1: Here is an example: Sub dural() MsgBox ActiveCell.Text End Sub This will insure that long strings of numerals are not converted to numbers. EDIT#1: This assumes that the cell actually displays the long string of numerals. If the cell displays #### , that is what the sub will pick-up. If

Get value from cell without transform in vba macros

南楼画角 提交于 2020-01-05 03:34:07
问题 I have an issue with vba macros. Cell contains value 941144280284022000000. But when try to get this value in macros, variable is equal 9.41144280284022E+20. Is it possible to get "real" value? Thanks. 回答1: Here is an example: Sub dural() MsgBox ActiveCell.Text End Sub This will insure that long strings of numerals are not converted to numbers. EDIT#1: This assumes that the cell actually displays the long string of numerals. If the cell displays #### , that is what the sub will pick-up. If

Application.OnTime not executed

亡梦爱人 提交于 2020-01-05 03:27:34
问题 I am trying to cancel a timer in the Workbook_Close routine in the ThisWorkbook module. Can anyone explain the following behaviour?: Closing the workbook manually Application.OnTime functions as expected and cancels the timer. If I try to kill the same timer more than once, or a non-existent timer, I get an error ERROR: 1004: Method 'OnTime' of object '_Application' failed To me, this is supporting evidence that the function is working properly. Closing the Workbook using ThisWorkbook.Close