excel-vba

Merge rows, sum one column of values, and keep earliest start time and latest end time - Part 2

£可爱£侵袭症+ 提交于 2020-01-15 20:14:57
问题 This question adds additional requirements to this question. This first screen shot shows all the columns and a sample of rows that we are working with. The data will be sorted. The sub will need to match all the data that is shown in Red text: The code will need to identify these and then merge the two rows, keeping the earliest Start date & time and the latest End date & time, and add the data in the last two columns respectively. In the below example the data values are 0 in the last

Dictionary inside a Dictionary

99封情书 提交于 2020-01-15 19:13:26
问题 I found an old method http://www.techbookreport.com/tutorials/vba_dictionary2.html to perform a dictionary inside a dictionary in VBA but in Excel 2013 modification in the Scripting library, I can't make the nesting work the same way. Or is there? Sub dict() Dim ws1 As Worksheet: Set ws1 = Sheets("BM") Dim family_dict As New Scripting.Dictionary Dim bm_dict As New Scripting.Dictionary Dim family As String, bm As String Dim i Dim ws1_range As Range Dim rng1 As Range With ws1 Set ws1_range =

Dictionary inside a Dictionary

混江龙づ霸主 提交于 2020-01-15 19:13:11
问题 I found an old method http://www.techbookreport.com/tutorials/vba_dictionary2.html to perform a dictionary inside a dictionary in VBA but in Excel 2013 modification in the Scripting library, I can't make the nesting work the same way. Or is there? Sub dict() Dim ws1 As Worksheet: Set ws1 = Sheets("BM") Dim family_dict As New Scripting.Dictionary Dim bm_dict As New Scripting.Dictionary Dim family As String, bm As String Dim i Dim ws1_range As Range Dim rng1 As Range With ws1 Set ws1_range =

Checking Data Types in a Range

耗尽温柔 提交于 2020-01-15 16:01:54
问题 I am trying to validate the data types of all cells in a user-selected range are the same, using a VBA function. I have the following code (simplified), which works for the most part: Dim vTempRange As Variant Dim vCell As Variant vTempRange = DataRange.Value For Each vCell In vTempRange If Len(vCell) > 0 Then 'Use TypeName(vCell) 'Complete validation here End If Next vCell Sometimes a user may select a column of percentages, sometimes a column of decimal values, and sometimes a time value

Checking Data Types in a Range

一个人想着一个人 提交于 2020-01-15 16:01:16
问题 I am trying to validate the data types of all cells in a user-selected range are the same, using a VBA function. I have the following code (simplified), which works for the most part: Dim vTempRange As Variant Dim vCell As Variant vTempRange = DataRange.Value For Each vCell In vTempRange If Len(vCell) > 0 Then 'Use TypeName(vCell) 'Complete validation here End If Next vCell Sometimes a user may select a column of percentages, sometimes a column of decimal values, and sometimes a time value

Checking Data Types in a Range

試著忘記壹切 提交于 2020-01-15 16:00:53
问题 I am trying to validate the data types of all cells in a user-selected range are the same, using a VBA function. I have the following code (simplified), which works for the most part: Dim vTempRange As Variant Dim vCell As Variant vTempRange = DataRange.Value For Each vCell In vTempRange If Len(vCell) > 0 Then 'Use TypeName(vCell) 'Complete validation here End If Next vCell Sometimes a user may select a column of percentages, sometimes a column of decimal values, and sometimes a time value

Copy data from excel to csv using macro

孤者浪人 提交于 2020-01-15 15:28:36
问题 I want to copy data from excel to csv but cant seem to find the correct logic. Below is how I want to copy the data. For example I want to copy data in cell D4 of excel to A4 in csv. I want to repeat this until a cell in column D is empty. "Excel ---> CSV "D4-->A4 "F4&G4-->B4 "K4-->E4 "L4-->F4 "N4-->G4 "P4-->I4 Sorry to ask such a basic question as I just started writing macros. Below is my code currently. This creates the csv file but does not populate the data I need. Sub csvfile() Dim fs

copy sheet content to another sheet

安稳与你 提交于 2020-01-15 14:09:50
问题 I want to copy the content of one sheet at the end of the other, i have tried this vba code and it works, Private Sub CommandButton1_Click() Sheets("B").Select Range("A1:H14").Select Range("A1:H14").Copy Sheets("A").Select ' Find the last row of data Range("B48:I48").Select ActiveSheet.Paste Sheets("A").Select End Sub but what i want is to copy without having to specify the range of the data, because i have many files and many data and it's gonna be hard to do all of that manually and change

TAB-key doesn't work after running macro

久未见 提交于 2020-01-15 13:34:15
问题 I have a sheet on which most cells are locked but a piece of the worksheet-cells is unlocked. I have a macro which does the following : unlock the workbook unlock the sheet copy that single sheet in another workbook save the new workbook somewhere and close it Afterwards, the tab-key doesn't work anymore. It looks like the worksheets loosed the focus, but as soon as I start typing, the content comes in the cell. When I select another workbook or another sheet in the original workbook, the tab

Excel 2013 macro to show only specific rows based on one cell value

扶醉桌前 提交于 2020-01-15 12:31:07
问题 i am new to excel macros and vba. I have an excel file with about 300000 rows in first sheet where there are item identifiers in first column(they might be several which has the same value), and about 1000 rows in second sheet(first column also contains item identifiers but they are unique here). i need to write a macro that hides rows in first sheet based on the second sheet. i mean i need to loop throw all rows in first sheet and if first cell value does not match any cell of first column