Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Find String in Cell then Paste Sum in Offset Cell

I am new to VBA and having an issue. I have a worksheet that contains
products and there prices (Note: Prices located in Col. F). My users add
products and remove products via UserForm when quoting prices to customers.
This causes the Cell that contains the SubTotal to move up and down as
products are added and removed.

I have tried to write my code to search down Col. E and find the cell
location of the String "Sub Total". Once the String Address is located, I
want to use Offset to show the Sum of the product prices next to the String
Cell in Col. F. I am getting an error "Object variable or block variable not
set" indicated below. Why?

Sub SubTotal()

Dim LastRow As Long
Dim mySubTotal As Range

Set mySubTotal = Sheets("QUOTE").Columns("E:E").Find(What:="Sub Total", _
After:=Cells(6, 5), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)


LastRow = Sheets("QUOTE").Range(mySubTotal.Address).Offset(-1, 0).Row

Sheets("QUOTE").Range(mySubTotal.Address).Offset(0 , 1).Value =
WorksheetFunction.Sum("F6:F" & LastRow - 1)

End Sub

Thanks in Advance,
Ryan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Find String in Cell then Paste Sum in Offset Cell

The replies to your earlier post didn't work?

RyanH wrote:

I am new to VBA and having an issue. I have a worksheet that contains
products and there prices (Note: Prices located in Col. F). My users add
products and remove products via UserForm when quoting prices to customers.
This causes the Cell that contains the SubTotal to move up and down as
products are added and removed.

I have tried to write my code to search down Col. E and find the cell
location of the String "Sub Total". Once the String Address is located, I
want to use Offset to show the Sum of the product prices next to the String
Cell in Col. F. I am getting an error "Object variable or block variable not
set" indicated below. Why?

Sub SubTotal()

Dim LastRow As Long
Dim mySubTotal As Range

Set mySubTotal = Sheets("QUOTE").Columns("E:E").Find(What:="Sub Total", _
After:=Cells(6, 5), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)


LastRow = Sheets("QUOTE").Range(mySubTotal.Address).Offset(-1, 0).Row

Sheets("QUOTE").Range(mySubTotal.Address).Offset(0 , 1).Value =
WorksheetFunction.Sum("F6:F" & LastRow - 1)

End Sub

Thanks in Advance,
Ryan


--

Dave Peterson
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
FIND / SEARCH text compare cell to string in 3rd cell nastech Excel Discussion (Misc queries) 0 October 29th 07 02:51 AM
Find word then use offset to change value in another cell [email protected][_2_] Excel Programming 4 June 7th 07 09:35 PM
Paste string on a cell to New Web Query URL vovlov Excel Discussion (Misc queries) 1 May 20th 06 12:58 PM
vba help pls - find min based on a condition and return val of an offset cell Impakt Excel Programming 2 May 17th 05 12:40 AM
VBA: Add cell value to another worksheet cell using Find and offset Caméléon Excel Programming 2 February 15th 05 04:07 AM


All times are GMT +1. The time now is 10:08 AM.

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"