Hi,
I took the following code from a forum, I have alreadly kindly had problem solved on this forum and have managed to come up with some solutions to others (though I am very new to Macros).
The Macro is to take data (weekly) and seperate it based on matching the name in Column 2.
Sheet 1 is where the data is input. There are simple formulas in Column 1 (A) and and also in columns 9/10. Which would be updated weekly.
The Problem: I need to copy the data (particularly) from Column A in the new sheets as Values (without the formulas).
I believe this is the code that needs to be changed.
I have tried adding to Copy Range & PasteValues in this line of code but to no avail.
I have added the copy Rows/Range - Paste.Vaules in earlier parts of the code which kind of works but changes either removes the formulas in the Sheet 1 or for some reason doubles the formulas (formula) + (ormula)
Would be grateful for any more advice.
Here is the total code just in Case
I took the following code from a forum, I have alreadly kindly had problem solved on this forum and have managed to come up with some solutions to others (though I am very new to Macros).
The Macro is to take data (weekly) and seperate it based on matching the name in Column 2.
Sheet 1 is where the data is input. There are simple formulas in Column 1 (A) and and also in columns 9/10. Which would be updated weekly.
The Problem: I need to copy the data (particularly) from Column A in the new sheets as Values (without the formulas).
I believe this is the code that needs to be changed.
VBA Code:
SHEET_EXISTS:
ws.Range("A" & titlerow & ":M" & lr).Offset(1).Copy Sheets(myarr(i) & "").Range("A" & Rows.Count).End(xlUp).Offset(1)
I have tried adding to Copy Range & PasteValues in this line of code but to no avail.
I have added the copy Rows/Range - Paste.Vaules in earlier parts of the code which kind of works but changes either removes the formulas in the Sheet 1 or for some reason doubles the formulas (formula) + (ormula)
Would be grateful for any more advice.
Here is the total code just in Case
VBA Code:
Sub parse_data()
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
Range("B2:H150").Select
Selection.replace What:="/", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="in which half more goal?", Replacement:="In Which half most Goals", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="Combo Doppia Chance & Multigoal Extra", Replacement:="Combo DC & Multigoal Exta", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="Team to Score", Replacement:="Teams Score", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="halftime", Replacement:="HT", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="Under/Over", Replacement:="U-O", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="Under Over", Replacement:="U-O", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="half time", Replacement:="HT", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="americanfootball", Replacement:="american football ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Selection.replace What:="tabletennis", Replacement:="table tennis", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
'Filtered Column Number
vcol = 2
'Worksheet to be split
Set ws = Sheets("Sheet1")
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
title = "A1:M1"
titlerow = ws.Range(title).Cells(1).Row
icol = ws.Columns.Count
ws.Cells(1, icol) = "Unique"
For i = 2 To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
ws.Columns(icol).clear
For i = 2 To UBound(myarr)
ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then GoTo SHEET_EXISTS
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
GoTo NEW_SHEET
SHEET_EXISTS:
ws.Range("A" & titlerow & ":M" & lr).Offset(1).Copy Sheets(myarr(i) & "").Range("A" & Rows.Count).End(xlUp).Offset(1)
NEW_SHEET:
Sheets(myarr(i) & "").Columns.AutoFit
If Sheet1.Range("r2").Value = 1 Then
Application.Run ("Module2.Button4_Click")
ElseIf Sheet1.Range("r2").Value < 1 Then
End If
Next
'Remove filter
ws.AutoFilterMode = False
ws.Activate
End Sub