excel-vba

Get worksheet property using worksheet variable

不问归期 提交于 2020-01-14 01:34:08
问题 I apologize if this has already been answered, but I had no luck searching on this. What’s the best way to access a worksheet property, when the worksheet is referenced by a variable? This one raises a compile error: Sub Tst1(Wk As Worksheet) Debug.Print Wk.pbOK End Sub This one works, but is there a better way? Thanks. Sub Tst2(Wk As Object) Debug.Print Wk.pbOK End Sub 回答1: With a tip from KazJaw, found out that you can get it compile no issues if: Sub Tst1(Wk As Worksheet) Debug.Print

insert rows after a data point changes

走远了吗. 提交于 2020-01-13 20:33:30
问题 I have a data set that looks like this: This1 GH This2 GH This3 GH This4 BR This5 BR This6 VB when the data point changes, i.e. "GH" to "BR" I want excel to insert a line break. so that the finalized data looks like this. This1 GH This2 GH This3 GH This4 BR This5 BR This6 VB any idea how this would be done? i think that a negative iterating for loop would work. but i don't know how excel would handle row manipulation in this case. 回答1: The fastest way to do it ( TRIED AND TESTED ) Option

Is there a way to trigger “track changes” through VBA in Excel?

喜你入骨 提交于 2020-01-13 20:30:10
问题 I want from VBA to start/stop "Track changes" functionality in Excel. Searching thru the Net I saw a property called TrackRevisions of ActiveDocument object. Supposedly in MS Word writing ActiveDocument.TrackRevisions = True should turn on "Track changes". But in MS Excel this line gives 424 Object required run-time error. Same error is returned when trying with ThisWorkbook . Changing it to ActiveSheet brings 438 Object doesn't support this property or method error. 回答1: For a shared

Is there a way to trigger “track changes” through VBA in Excel?

十年热恋 提交于 2020-01-13 20:29:34
问题 I want from VBA to start/stop "Track changes" functionality in Excel. Searching thru the Net I saw a property called TrackRevisions of ActiveDocument object. Supposedly in MS Word writing ActiveDocument.TrackRevisions = True should turn on "Track changes". But in MS Excel this line gives 424 Object required run-time error. Same error is returned when trying with ThisWorkbook . Changing it to ActiveSheet brings 438 Object doesn't support this property or method error. 回答1: For a shared

Is there a way to trigger “track changes” through VBA in Excel?

元气小坏坏 提交于 2020-01-13 20:29:31
问题 I want from VBA to start/stop "Track changes" functionality in Excel. Searching thru the Net I saw a property called TrackRevisions of ActiveDocument object. Supposedly in MS Word writing ActiveDocument.TrackRevisions = True should turn on "Track changes". But in MS Excel this line gives 424 Object required run-time error. Same error is returned when trying with ThisWorkbook . Changing it to ActiveSheet brings 438 Object doesn't support this property or method error. 回答1: For a shared

VBA catch the “calculate sheet (shift+f9)” and “calculate workbook” events

我只是一个虾纸丫 提交于 2020-01-13 19:09:23
问题 I don't know if this is trivial or actually hacky to do : is it possible to catch the "calculate sheet (shift+f9)" and "calculate workbook" events in VBA ? I want to hide some processes that manipulate a few thousands lines, to just display some key values. I am calculating a distribution, the thousands lines, and want to just output the percentiles and some stats, as well as the graph instead of all these lines. At the moment I was thinking of a classic macro button, but my users are keener

VBA catch the “calculate sheet (shift+f9)” and “calculate workbook” events

故事扮演 提交于 2020-01-13 19:09:16
问题 I don't know if this is trivial or actually hacky to do : is it possible to catch the "calculate sheet (shift+f9)" and "calculate workbook" events in VBA ? I want to hide some processes that manipulate a few thousands lines, to just display some key values. I am calculating a distribution, the thousands lines, and want to just output the percentiles and some stats, as well as the graph instead of all these lines. At the moment I was thinking of a classic macro button, but my users are keener

Code that changes chart position requires my target sheet to be Activated?

两盒软妹~` 提交于 2020-01-13 18:24:09
问题 I use this code to dynamically change the size of a chart and its position on the sheet. As I add a new line of data daily, I shift a bunch of charts down on the page to line up with the new last row. What I DON'T understand is why I need the sheet with the charts on it to be activated in order for this to work properly. Before anyone asks, my lastrow value is being retrieved explictly, so none of my values are being interpreted from an ActiveSheet . However, I still have this issue... Here

Excel VBA - Saving Charts as GIF files

喜你入骨 提交于 2020-01-13 18:23:38
问题 Programming is not my primary work function, but appearing to be the swiss army knife that I am regarded, I have been tasked with making a VBA macro in Excel that exports graphs to gif files for an automated update of info-screens in our manufacturing plants. I have a macro that works, however, it sometimes fails and creates a gif with the correct file name but "empty" graph. The user defines their own export path in a range in the worksheet as well as the dimensions of the exported chart.

Excel VBA - Saving Charts as GIF files

天大地大妈咪最大 提交于 2020-01-13 18:23:28
问题 Programming is not my primary work function, but appearing to be the swiss army knife that I am regarded, I have been tasked with making a VBA macro in Excel that exports graphs to gif files for an automated update of info-screens in our manufacturing plants. I have a macro that works, however, it sometimes fails and creates a gif with the correct file name but "empty" graph. The user defines their own export path in a range in the worksheet as well as the dimensions of the exported chart.