Hi guys,
First post but still a frequent board user... 
Here's my issue!
I have a workbook with 2 spreadsheet, let's say A & B.
I now use a VBA-script to go through all rows in that spreadsheet A1 and if column e of that row contains the value "0"
I then move it to spreadsheet B. All other values remain in its origin place in sheet A.
I've also added 4 CF-rules to the active area (let's say $A$1:$E$20), which means that depending of the value in a certain columns
it shifts the background color between 4 different colors.
It all works pretty fine, but VERY slow since I use a loop function i found online, and as I'm pretty new to VBA I don't have the skills
to build the same thing from scratch. So
My issues are:
1) Is there a better (faster) way to get the same result? Clean the code or rewrite it, if so -how?
2) When a row is copied from sheet A to sheet B, it pastes everything including the CF-rules, I just want to paste
the formulas (and thereby the textvalues and the formulas my cell contains) from sheet A to Sheet B (expect the CF).
The reason to this is that I want to use the CF-rule that are applied in Sheet B.
What happens now is, that it ADDS the four rules rules mentioned above, from sheet A to Sheet B, where sheet B already contains the same rules) but in an expanded area ($A$1:$E$200). Where does it do wrong?
Heres my code:
Sub FlyttaTillDatabas()
Dim xrow As Long
xrow = 2
Sheets("Prospects").Select
Dim LastRow As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
Application.Calculation = xlManual
Do Until xrow = LastRow + 1
ActiveSheet.Cells(xrow, 28).Select
If ActiveCell.Value = "0" Then
Selection.EntireRow.Cut
Sheets("Databas").Select
ActiveSheet.Range("SistaCell").Select
ActiveSheet.Paste
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteFormulas
Selection.FormatConditions.Delete
Application.CutCopyMode = False
Sheets("Prospects").Select
ActiveCell.Select
Selection.EntireRow.Delete
xrow = xrow - 1
End If
xrow = xrow + 1
Loop
Application.ScreenUpdating = True
Range("p2").Select
Application.Calculation = xlAutomatic
End Sub
I've steped into it 100 times, and it seems that it's on the line...
"ActiveSheet.Paste"
...where it pastes everything (incl. the CF) that I DON'T WANT, and then 2 code rows later, it pastes everything aging,
but this time it pastes it what I'm asking for.
I'm not sure if the code is optimized for this purpose, so please review it and get back to me with any changes that might help.
Thank you in advance!
PS. I'm using Excel 2007 if that helps
Bookmarks