Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default reference error

I have a 2 tab spreadsheet. On sheet 1 (SBX WORK SHEET) I calculate unit
price (E18) by multiplying the actual cost (G18) by a markup in cell (E14).
By changing the markup value in E14 the salemen can adjust their margin. That
works fine.

Tab 2 (SBX COST SHEET) runs a macro that works on other spreadsheets where
if the quantity is a number the entire line is written to a "quote sheet".
The macro is below:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
..EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Range("a17")
End If
End If
End With
Next iRow
Next wks
End Sub
The problem is when I run the macro I get a #REF error in the Unit Price
Column on the SBX COST SHEET. It appears that it does not like the value. Any
help will be appreciated.

Jerry
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default reference error

I'm guessing that you have formulas in the row you are copying and you should
probably be doing a PasteSpecial Paste:=xlPasteValues.

"Jerry Foley" wrote:

I have a 2 tab spreadsheet. On sheet 1 (SBX WORK SHEET) I calculate unit
price (E18) by multiplying the actual cost (G18) by a markup in cell (E14).
By changing the markup value in E14 the salemen can adjust their margin. That
works fine.

Tab 2 (SBX COST SHEET) runs a macro that works on other spreadsheets where
if the quantity is a number the entire line is written to a "quote sheet".
The macro is below:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Range("a17")
End If
End If
End With
Next iRow
Next wks
End Sub
The problem is when I run the macro I get a #REF error in the Unit Price
Column on the SBX COST SHEET. It appears that it does not like the value. Any
help will be appreciated.

Jerry

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default reference error

Thanks,
Where would that go in the macro?

"JLGWhiz" wrote:

I'm guessing that you have formulas in the row you are copying and you should
probably be doing a PasteSpecial Paste:=xlPasteValues.

"Jerry Foley" wrote:

I have a 2 tab spreadsheet. On sheet 1 (SBX WORK SHEET) I calculate unit
price (E18) by multiplying the actual cost (G18) by a markup in cell (E14).
By changing the markup value in E14 the salemen can adjust their margin. That
works fine.

Tab 2 (SBX COST SHEET) runs a macro that works on other spreadsheets where
if the quantity is a number the entire line is written to a "quote sheet".
The macro is below:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Range("a17")
End If
End If
End With
Next iRow
Next wks
End Sub
The problem is when I run the macro I get a #REF error in the Unit Price
Column on the SBX COST SHEET. It appears that it does not like the value. Any
help will be appreciated.

Jerry

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default reference error

Replace these lines:

..EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Range("a17")

With:

..EntireRow.Copy
Worksheets("SBX COST SHEET").Range("a17") _
.PasteSpecial Paste:=xlPasteValues





"Jerry Foley" wrote:

Thanks,
Where would that go in the macro?

"JLGWhiz" wrote:

I'm guessing that you have formulas in the row you are copying and you should
probably be doing a PasteSpecial Paste:=xlPasteValues.

"Jerry Foley" wrote:

I have a 2 tab spreadsheet. On sheet 1 (SBX WORK SHEET) I calculate unit
price (E18) by multiplying the actual cost (G18) by a markup in cell (E14).
By changing the markup value in E14 the salemen can adjust their margin. That
works fine.

Tab 2 (SBX COST SHEET) runs a macro that works on other spreadsheets where
if the quantity is a number the entire line is written to a "quote sheet".
The macro is below:
Option Explicit
Sub mastertest2()
Dim rSource As Range
Dim rCell As Range
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

For Each wks In Worksheets(Array("SBX WORK SHEET"))
With wks
FirstRow = 4
LastRow = .Cells(.Rows.Count, 4).End(xlUp).Row
End With

For iRow = LastRow To FirstRow Step -1
Set rCell = wks.Cells(iRow, 4)
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
Worksheets("SBX COST SHEET").Rows(17).Insert
.EntireRow.Copy _
Destination:=Worksheets("SBX COST SHEET").Range("a17")
End If
End If
End With
Next iRow
Next wks
End Sub
The problem is when I run the macro I get a #REF error in the Unit Price
Column on the SBX COST SHEET. It appears that it does not like the value. Any
help will be appreciated.

Jerry

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
#N/A Error Reference Sergio Excel Worksheet Functions 2 November 2nd 09 06:09 PM
Breaking a Reference Error Cresta Excel Programming 0 August 5th 08 04:14 PM
reference #value error DrXerox Excel Worksheet Functions 0 July 22nd 05 03:56 AM
Reference Error RB Smissaert Excel Programming 0 July 30th 04 10:28 PM
VBA reference error Thor[_2_] Excel Programming 1 January 7th 04 09:46 PM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"