vba

Filtered Row Count

▼魔方 西西 提交于 2021-02-15 07:46:59
问题 In VBA, I wish to find the row count of a filtered column, so I wrote VBA code as FilteredRowCount = ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Rows.Count But FilteredRowCount always return value of 1, what would cause this? 回答1: Do like this Sub test() Dim Ws As Worksheet Dim rngDB As Range Dim r As Integer Dim rng As Range Set Ws = ActiveSheet Set rngDB = Ws.UsedRange.SpecialCells(xlCellTypeVisible) For Each rng In rngDB.Areas r = r + rng.Rows.Count Next rng MsgBox r End Sub 来源:

open all hyperlinks from selected column at once in excel

久未见 提交于 2021-02-15 07:40:46
问题 I want to open all the hyperlinks in a column at once, code i used is Sub OpenLinks() Dim HL As Hyperlink For Each HL In Selection.Hyperlinks HL.Follow Next End Sub this macro works fine when i select the cell containing www.google.com but dont work when I select cell next to it and run the macro i have created the links mentioned in green and red column using the formula from this question https://stackoverflow.com/a/65867184/14713550 edit 回答1: I think you are looking something below. Follow

How can I speed up this For Each loop in VBA?

十年热恋 提交于 2021-02-15 06:46:37
问题 I have an Worksheet_Change macro that hides/unhides rows depending on the choice a user makes in a cell with a data validation list. The code takes a minute to run. It's looping over c.2000 rows. I'd like it to take closer to a few seconds so it becomes a useful user tool. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) 'Exit the routine early if there is an error On Error GoTo EExit 'Manage Events Application.ScreenUpdating = False Application.DisplayAlerts = False

VBA Excel filter data and copy to another worksheet - Newbie alert

喜你入骨 提交于 2021-02-15 03:01:02
问题 Hi I am a complete newbie when it comes to VBA Excel. Im trying to filter a variable sized spreadsheet full of data looking for a set word in one column. Once found I want to copy the complete row to another worksheet. As they maybe more than one row with this word in it I don't want to write over the previous copied row. this is what ive created to find the word, but how do I copy the row to another worksheet? Sheets("Sheet1").Select 'Select datasheet Range("A1").Select 'Set cell position to

VBA Excel filter data and copy to another worksheet - Newbie alert

杀马特。学长 韩版系。学妹 提交于 2021-02-15 02:59:35
问题 Hi I am a complete newbie when it comes to VBA Excel. Im trying to filter a variable sized spreadsheet full of data looking for a set word in one column. Once found I want to copy the complete row to another worksheet. As they maybe more than one row with this word in it I don't want to write over the previous copied row. this is what ive created to find the word, but how do I copy the row to another worksheet? Sheets("Sheet1").Select 'Select datasheet Range("A1").Select 'Set cell position to

Optimizing the VBA Code and improve the performance

不问归期 提交于 2021-02-13 11:24:25
问题 I have developed a VBA macro which is used to refresh the 5 SAP AAO Queries and then copy those queries data into tables saperately by removing duplicates and then loaded into the power query. There i add some calculated columns and then load that data into the power pivots. I have also used the VBA code mentioned below to perform some actions in each of the sheets, however it is currently taking more than 4 minutes to run the code. In that 4 minutes at least 45 seconds are going for

VBA paste as values - how to

我与影子孤独终老i 提交于 2021-02-12 11:39:55
问题 I have some VBA code that copys a range from one sheet and then pastes it to another at the first blank line. What it is copying are vlookup formulas so when it pastes it pastes all 0's, how would I go about getting it to paste what it copies as values so the results are retained? Code: Private Sub PasteChartDataQtyCompare() 'This step pastes the range of values to the chart data tab Sheets(1).Range("A6:J22").Copy _ Destination:=Sheets("Chart Data").Cells(Sheets("Chart Data").Rows.Count, 1)

VBA: Chart_Data points not visible in graph

喜你入骨 提交于 2021-02-11 18:24:39
问题 I dont get the line curve for the data given below however I see the data being plotted but not visible as a smooth line. Please help. Column B Column C x y 0.00 0.00 -0.10 0.29 -0.35 0.48 -0.65 0.48 -0.90 0.29 -1.00 0.00 Set ch = ActiveSheet.ChartObjects("Chart 1") ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ch.Activate p=1 For i = 1 To 6 ser_count = ActiveChart.SeriesCollection.Count p = ser_count + 1 ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(p).XValues =

VBA set a Loop for specific worksheets in a workbook

ε祈祈猫儿з 提交于 2021-02-11 18:21:33
问题 I run a monthly report that generates 16 tabs (15 worksheets: "Report1" - "Report15"). I've created a sub to create/format a table, and organize the data on Sheet2("Report1"). Objective: Because of the Table Style, I would now like to loop the macro through "Report1", "Report4", "Report7", "Report10", "Report13" Only. (Once I figure this out, I'll create a Macro with another Table Style for the other worksheets.) Issues: Through 'Googling' I created the below Loop, but the "Set ws =

VBA set a Loop for specific worksheets in a workbook

情到浓时终转凉″ 提交于 2021-02-11 18:21:28
问题 I run a monthly report that generates 16 tabs (15 worksheets: "Report1" - "Report15"). I've created a sub to create/format a table, and organize the data on Sheet2("Report1"). Objective: Because of the Table Style, I would now like to loop the macro through "Report1", "Report4", "Report7", "Report10", "Report13" Only. (Once I figure this out, I'll create a Macro with another Table Style for the other worksheets.) Issues: Through 'Googling' I created the below Loop, but the "Set ws =