Having a problem with my macro moving data from one sheet to another

Yaku

New Member
Joined
Nov 7, 2009
Messages
4
I'm about 95% of the way done but this last 5% is giving me some problems. I'm trying to copy data from "getPlays" worksheet to the first blank row in "Count" worksheet. So far so good, the macro below does the job.

The problem I'm having is that it is copying the formula over to "Count" rather than value. Instead of copying "=P2+q2", I want the answer (7). Seems like a simple problem but I'm having major brainlock with it.


Code:
Sub test2()With Application

.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
Sheets("getPlays").Select
Dim NextRow&, LastRow&, i%

Sheets.Add(After:=Sheets(ActiveSheet.Index)).Name = "ZZZtemp"
For i = 1 To 27
Cells(1, i).FormulaArray = "=MAX(IF(LEN(TRIM(getPlays!RC:R1000C))>0,ROW(getPlays!RC:R1000C),""""))"
Next i
LastRow = WorksheetFunction.Max(Range("A1").CurrentRegion)

ActiveSheet.Delete
With Sheets("count")
NextRow = .Cells.Find(What:="*", After:=.Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Sheets("getPlays").Range("A1:s" & LastRow).copy .Cells(NextRow, 1)
End With
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi Yaku. Change this line:
Code:
Sheets("getPlays").Range("A1:s" & LastRow).copy .Cells(NextRow, 1)
to
this:
Code:
Sheets("getPlays").Range("A1:s" & LastRow).Copy
.Cells(NextRow, 1).PasteSpecial xlPasteValues
 
Upvote 0
Rich (BB code):
Sub test2()
With Application

.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
Sheets("getPlays").Select
Dim NextRow&, LastRow&, i%

Sheets.Add(After:=Sheets(ActiveSheet.Index)).Name = "ZZZtemp"
For i = 1 To 27
Cells(1, i).FormulaArray = "=MAX(IF(LEN(TRIM(getPlays!RC:R1000C))>0,ROW(getPlays!RC:R1000C),""""))"
Next i
LastRow = WorksheetFunction.Max(Range("A1").CurrentRegion)

ActiveSheet.Delete
With Sheets("count")
NextRow = .Cells.Find(What:="*", After:=.Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Sheets("getPlays").Range("A1:s" & LastRow).Copy
.Cells(NextRow, 1).PasteSpecial Paste:=xlPasteValues
End With
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
 
Upvote 0
It looks like you're getting an error on the highlighted line. Try changing this:
Code:
NextRow = .Cells.Find(What:="*", After:=.Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Sheets("getPlays").Range("A1:s" & LastRow).Copy
[COLOR=#ff0000].Cells(NextRow, 1).PasteSpecial Paste:=xlPasteValues[/COLOR]
to this:
Code:
Dim bottomA As Integer
bottomA = Range("A" & Rows.Count).End(xlUp).Row
Sheets("Sheet2").Range("A1").Copy
.Cells(bottomA + 1, 1).PasteSpecial Paste:=xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,203,172
Messages
6,053,905
Members
444,694
Latest member
JacquiDaly

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top