Hello All,
I'm newer to Excel Macros and I have a lengthy manual data manipulation I'm trying to automate as much as I can. I get data in an excel sheet with many different columns and almost 10k rows and it needs parsed out to about 7 different sheets within the workbook based on the starting cell value in one column. I posted example data below. Basically I want to create a range variable, say Test_Range, and add the rows where the value in column D start with "H" so that I can cut and paste to another workbook. I'm lost as far as appending the variable. I figured I'd be using a For loop to iterate through the table (Like For Each cell In [D:D]), and then an If cell.value Like "H*" Then, but I don't understand how to add the range("A2:H2") to the variable while within the If statement but using variables. This is my thought process thus far and my current block.
Sub Parsed_Data()
Dim Test_Range as Range
For Each cell In [D:D]
-If cell.value Like "H*" Then
--Dim Row_Num As Integer
--Row_Num = cell.Row
--Dim Found_Range As Range
--Set Found_Range = ("A + Row_Num:H + Row_Num")
--Test_Range = Union(Test_Range, Found_Range)
--Else
--Endif
-Endif
Next cell
End Sub
I'm getting errors on the Line --Set Found_Range = ("A + Row_Num:H + Row_Num") for type mismatch.
I hope I'm making sense.
I'm newer to Excel Macros and I have a lengthy manual data manipulation I'm trying to automate as much as I can. I get data in an excel sheet with many different columns and almost 10k rows and it needs parsed out to about 7 different sheets within the workbook based on the starting cell value in one column. I posted example data below. Basically I want to create a range variable, say Test_Range, and add the rows where the value in column D start with "H" so that I can cut and paste to another workbook. I'm lost as far as appending the variable. I figured I'd be using a For loop to iterate through the table (Like For Each cell In [D:D]), and then an If cell.value Like "H*" Then, but I don't understand how to add the range("A2:H2") to the variable while within the If statement but using variables. This is my thought process thus far and my current block.
Sub Parsed_Data()
Dim Test_Range as Range
For Each cell In [D:D]
-If cell.value Like "H*" Then
--Dim Row_Num As Integer
--Row_Num = cell.Row
--Dim Found_Range As Range
--Set Found_Range = ("A + Row_Num:H + Row_Num")
--Test_Range = Union(Test_Range, Found_Range)
--Else
--Endif
-Endif
Next cell
End Sub
I'm getting errors on the Line --Set Found_Range = ("A + Row_Num:H + Row_Num") for type mismatch.
I hope I'm making sense.