excel-vba

Customize ActiveX button from VBA

白昼怎懂夜的黑 提交于 2020-03-03 12:58:22
问题 I've made a piece of code that, when you click a button, copies a sheet, strips it for formatting and then adds a new button with a different macro assigned to it. My problem is that both of my buttons are grey, and I would like to customize them. The first button is an Excel control element, and is always present on the original sheet. I've altered the font, font size, underlining and made it bold, by right clicking on it and entering the formatting menu, but I can't find the option to

Customize ActiveX button from VBA

社会主义新天地 提交于 2020-03-03 12:58:12
问题 I've made a piece of code that, when you click a button, copies a sheet, strips it for formatting and then adds a new button with a different macro assigned to it. My problem is that both of my buttons are grey, and I would like to customize them. The first button is an Excel control element, and is always present on the original sheet. I've altered the font, font size, underlining and made it bold, by right clicking on it and entering the formatting menu, but I can't find the option to

Union of Ranges out of order

徘徊边缘 提交于 2020-03-03 11:58:27
问题 I am trying to copy various ranges in a certain order, and than paste them from a workbook into a different workbook. Currently I have set my ranges eg Set rg = ws1.Range("A2:A" & i).Offset(rowOffset:=1, columnOffset:=0) Set rg1 = ws1.Range("Z2:Z" & i).Offset(rowOffset:=1, columnOffset:=0) Set rg2 = ws1.Range("C2:C" & i).Offset(rowOffset:=1, columnOffset:=0) Set TradesCopy = Union(rg, rg1, rg2) So typically what should happen is that it should be pasting in those ranges in that order (rg, rg1

Windows Task Manager Schedule VBA Macro to Send An Email Using OutLook Daily Running Manually and Not Automatically

拈花ヽ惹草 提交于 2020-03-03 10:11:09
问题 I have my macro which is running, & for this I created a vb script and used windows task manager to schedule its run every day. Whenever I run manually or attempt changing the time in the trigger, I always make sure that both excel and outlook are not running. If I run the macro in Excel VBA, it sends the email. After scheduling the task to run everyday, just as a test if I go to (in TaskScheduler) View -> Hidden Tasks and manually click Run, it sends the email. However, if I schedule it to

Cannot run the macro

久未见 提交于 2020-03-03 05:36:01
问题 I have encountered a problem in the macro below Sub RefreshAction() Range("b7").Select Application.Run "RefreshCurrentSelection" Application.OnTime (Now() + TimeValue("00:00:05")), "thisworkbook.Action" End Sub The cell refreshes when I run the macro the first time but I get the error message immediately after Message: Cannot run the macro "C\Desktop\XYZ.xlsm'!thisworkbook.Action'. The macro may not be available in this workbook or all macros may be disabled. I have already gone through

Vba: display decimals with point and not coma

喜欢而已 提交于 2020-03-03 03:00:50
问题 I would like to have all numbers in a macro displayed with point and not coma For Instance This display "0,03" but I would like "0.03": Dim MyNumber As Single MyNumber = 0.03 MsgBox (MyNumber) I have tried a set of codes that does not work: this still displays the Coma: Application.DecimalSeparator = "." this still displays the Coma and does not apply to the whole macro MyNumber = Format(MyNumber, "##0.00") this displays dot instead of coma but does not apply to the whole macro MsgBox

VBA power operator (^) not working as expected in 64-bit VBA [duplicate]

北城余情 提交于 2020-03-02 10:09:59
问题 This question already has an answer here : Why do I need a space before the '^' operator in VBA for Excel 2013 or it will produce a compile time error “Expected list or separator” (1 answer) Closed 2 years ago . I feel foolish for asking and I'm sure there's a simple answer. I'm trying to get a power for a number as follows: Sub test() Dim number As Long number = 2^8 ' Expect to get 256 here End Sub This produces an error: 'Expected: list separator or )'. I'm surprised this doesn't work. I'm

VBA power operator (^) not working as expected in 64-bit VBA [duplicate]

你离开我真会死。 提交于 2020-03-02 10:06:32
问题 This question already has an answer here : Why do I need a space before the '^' operator in VBA for Excel 2013 or it will produce a compile time error “Expected list or separator” (1 answer) Closed 2 years ago . I feel foolish for asking and I'm sure there's a simple answer. I'm trying to get a power for a number as follows: Sub test() Dim number As Long number = 2^8 ' Expect to get 256 here End Sub This produces an error: 'Expected: list separator or )'. I'm surprised this doesn't work. I'm

Convert Hyperlinks to HTML code in Excel

五迷三道 提交于 2020-03-01 23:11:10
问题 I have a column of hyperlinks in an Excel file and I want to convert them to their respective HTML code: <a href="http://www.example.com">Link Name</a> I found ways to extract the link only (as text), but I need the whole HTML code as text to replace the hyperlink in the cell. I've searched and searched but no one needed this answer, I guess. Can someone help? 回答1: It is actually a fairly straightforward method to yank the .Address and optional .SubAddress from the Hyperlinks collection

Excel VBA - Check if a worksheet is protected WITH A PASSWORD

怎甘沉沦 提交于 2020-03-01 15:11:03
问题 We can check if a sheet is protected using ProtectContents property. But how check if it is protected with a password? if ws.ProtectContents then ''do something end if 回答1: I don't believe there is a direct way of doing this by way of a property. Alternatively, though, you could attempt to unprotect the worksheet with a blank password and catch the error should it fail: Function isSheetProtectedWithPassword(ws As Worksheet) As Boolean If ws.ProtectContents Then On Error GoTo errorLabel ws