Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Active Sheet as Variable

Sub FirstMoveToQuoteSheet()
Dim QuoteSht As Worksheet
Dim Log As Worksheet
Dim Opn As String

Set QuoteSht = AvtiveSheet
Opn = "G:\New Items\Tracking Lists\" & QuoteSht.Range("R15") = _
Left(QuoteSht.Range("H2"), 2) & " Quotation Tracking Log.xls"
MsgBox QuoteSht
Workbooks.Open Filename:=Opn


End Sub
Here is the code. It bugs out on msgbox. The Quotesheet is set to
nothing. any help would be greatly appreciated.
Thanks,
Jay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Set Active Sheet as Variable

1. should be:
Set QuoteSht = ActiveSheet
(instead of AvtiveSheet)

2. MsgBox QuoteSht
what do you need this message box for? you only can place a string in
MsgBox (sth. like QuoteSht.Name)
QuoteSht cannot be placed in a MsgBox since it is an object
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Active Sheet as Variable

On Dec 8, 8:22*am, Jarek Kujawa wrote:
1. should be:
Set QuoteSht = ActiveSheet
(instead of AvtiveSheet)

2. MsgBox QuoteSht
what do you need this message box for? you only can place a string in
MsgBox (sth. like QuoteSht.Name)
QuoteSht cannot be placed in a MsgBox since it is an object


I am sorry that I wasted your time. I am definitly having a Monday.
I had not typed correctly. In the code I had ActiveSheet and not
Avtive. Plus the biggest problem was that I had a poor reference to
what I wanted to open. After I removed the Range(r15) = something
part, it works great.

Set QuoteSht = ActiveSheet

Opn = "G:\New Items\Tracking Lists\" & Left(QuoteSht.Range("H2"),
2) & _
" Quotation Tracking Log.xls"
Workbooks.Open Filename:=Opn
Sorry,
Jay
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Set Active Sheet as Variable

welcome
I also hate Mondays
;-)
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Active Sheet as Variable

I have another problem. I hope it is not as stupid. VBA is not
letting me set Log = WrkBk.Sheet1. Why?

Opn = "G:\New Items\Tracking Lists\" & Left(QuoteSht.Range("H2"),
2) & _
" Quotation Tracking Log.xls"
Set WrkBk = Workbooks.Open(Opn)
Set Log = WrkBk.Sheet1

Thanks,
Jay


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Set Active Sheet as Variable

try:
Set Log = WrkBk.Sheets("Sheet1")

be sure not to put any dot at the end of the line
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Set Active Sheet as Variable

On Dec 8, 9:18*am, Jarek Kujawa wrote:
try:
Set Log = WrkBk.Sheets("Sheet1")

be sure not to put any dot at the end of the line


The sheet is not called Sheet1 it is sheet1 of the workbook that I am
opening. Here is all the code so you can see what I am trying to do.

Thanks,
Jay

Sub FirstMoveToQuoteSheet()
Dim Log As Worksheet
Dim WrkBk As Workbook
Dim QuoteNum As String
Dim Comp As String
Dim Desc As String
Dim Dt As Date
Dim Cont As String
Dim Opn As String
Dim QuoteRow As Long

Comp = Range("K1")
Desc = Range("I3")
Dt = Range("H1").Value
Cont = Range("K2")
QuoteNum = Range("H2")
Opn = "G:\New Items\Tracking Lists\" & Left(Range("H2"), 2) & _
" Quotation Tracking Log.xls"
Set WrkBk = Workbooks.Open(Opn)
Set Log = WrkBk.Sheets("Sheet1")
QuoteRow = Log.Range("A:A").Find(What:=QuoteNum,
LookIn:=xlValues).Row
Log.Range("B" & QuoteRow) = Comp
Log.Range("C" & QuoteRow) = Desc
Log.Range("D" & QuoteRow) = Dt
Log.Range("K" & QuoteRow) = Cont
WrkBk.Close Savechanges:=True
End Sub
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default Set Active Sheet as Variable

don't know
I'd activate sheet1 before it's range
e.g. Log.Activate
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
Copy sheet and make new sheet active belvy123 Excel Discussion (Misc queries) 5 April 24th 08 03:33 PM
Set a variable to the active cell Richard Excel Discussion (Misc queries) 1 March 24th 08 05:42 PM
Active Cell Copy And Paste Sheet to Sheet A.R.J Allan Jefferys New Users to Excel 4 May 4th 06 02:04 AM
variable in a link where the variable is the name of the sheet darrelly Excel Worksheet Functions 1 October 7th 05 08:24 AM
Using the Active cell in one sheet for another sheet JOHNNY_E Excel Discussion (Misc queries) 0 May 4th 05 06:19 AM


All times are GMT +1. The time now is 01:52 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"