Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Referencing date and worksheet tab

I would like to take a main workbook and right a code into my current code
that would look at the date on the main workbook and cross refernce that to
the data workbook. The data workbook already has the tabs named for each day
of the month (1,2,3,4...). I have a main worksheet that has the =now()
producing the date in format dd. How do I make this dynamic so that it will
look at different tabs that corrispond with the current date??
This is the current code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/5/2006 by Eric Wagner
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls"
Sheets("1").Select
ActiveWindow.SmallScroll Down:=13
Range("C58").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.ActivateNext
Range("G6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ActivateNext
ActiveWindow.Close
End Sub

--
EW - Analyst
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Referencing date and worksheet tab

Maybe something like this:

Option Explicit
sub testme()

dim MainWks as worksheet
Dim DateCell as range
dim DateWks as worksheet
dim DateWkbk as workbook

set mainwks = thisworkbook.worksheets("Main")
set datecell = mainwks.range("a1")

set datewkbk = Workbooks.Open(Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls")

set datewks = datewkbk.worksheets(cstr(datecell.text))

'do what you need to do to datewks??
datewks.range("a1:b99").copy _
destination:=mainwks.range("x99")

datewkbk.close savechanges:=false

end sub

Untested, but it compiled ok.

ewagz wrote:

I would like to take a main workbook and right a code into my current code
that would look at the date on the main workbook and cross refernce that to
the data workbook. The data workbook already has the tabs named for each day
of the month (1,2,3,4...). I have a main worksheet that has the =now()
producing the date in format dd. How do I make this dynamic so that it will
look at different tabs that corrispond with the current date??
This is the current code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/5/2006 by Eric Wagner
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls"
Sheets("1").Select
ActiveWindow.SmallScroll Down:=13
Range("C58").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.ActivateNext
Range("G6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ActivateNext
ActiveWindow.Close
End Sub

--
EW - Analyst


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Referencing date and worksheet tab

The date portion worked great! Is there a way to have it paste the data in
the last part of the code to paste special with value only?

'do what you need to do to datewks??
DateWks.Range("C58").Copy _
Destination:=MainWks.Range("G6")

DateWkbk.Close savechanges:=False
--
EW - Analyst


"Dave Peterson" wrote:

Maybe something like this:

Option Explicit
sub testme()

dim MainWks as worksheet
Dim DateCell as range
dim DateWks as worksheet
dim DateWkbk as workbook

set mainwks = thisworkbook.worksheets("Main")
set datecell = mainwks.range("a1")

set datewkbk = Workbooks.Open(Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls")

set datewks = datewkbk.worksheets(cstr(datecell.text))

'do what you need to do to datewks??
datewks.range("a1:b99").copy _
destination:=mainwks.range("x99")

datewkbk.close savechanges:=false

end sub

Untested, but it compiled ok.

ewagz wrote:

I would like to take a main workbook and right a code into my current code
that would look at the date on the main workbook and cross refernce that to
the data workbook. The data workbook already has the tabs named for each day
of the month (1,2,3,4...). I have a main worksheet that has the =now()
producing the date in format dd. How do I make this dynamic so that it will
look at different tabs that corrispond with the current date??
This is the current code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/5/2006 by Eric Wagner
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls"
Sheets("1").Select
ActiveWindow.SmallScroll Down:=13
Range("C58").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.ActivateNext
Range("G6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ActivateNext
ActiveWindow.Close
End Sub

--
EW - Analyst


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Referencing date and worksheet tab

datewks.range("C58").copy
mainwks.range("g6").pastespecial paste:=xlpastevalues

or

mainwks.range("g6").value = datewks.range("C58").value



ewagz wrote:

The date portion worked great! Is there a way to have it paste the data in
the last part of the code to paste special with value only?

'do what you need to do to datewks??
DateWks.Range("C58").Copy _
Destination:=MainWks.Range("G6")

DateWkbk.Close savechanges:=False
--
EW - Analyst

"Dave Peterson" wrote:

Maybe something like this:

Option Explicit
sub testme()

dim MainWks as worksheet
Dim DateCell as range
dim DateWks as worksheet
dim DateWkbk as workbook

set mainwks = thisworkbook.worksheets("Main")
set datecell = mainwks.range("a1")

set datewkbk = Workbooks.Open(Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls")

set datewks = datewkbk.worksheets(cstr(datecell.text))

'do what you need to do to datewks??
datewks.range("a1:b99").copy _
destination:=mainwks.range("x99")

datewkbk.close savechanges:=false

end sub

Untested, but it compiled ok.

ewagz wrote:

I would like to take a main workbook and right a code into my current code
that would look at the date on the main workbook and cross refernce that to
the data workbook. The data workbook already has the tabs named for each day
of the month (1,2,3,4...). I have a main worksheet that has the =now()
producing the date in format dd. How do I make this dynamic so that it will
look at different tabs that corrispond with the current date??
This is the current code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/5/2006 by Eric Wagner
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls"
Sheets("1").Select
ActiveWindow.SmallScroll Down:=13
Range("C58").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.ActivateNext
Range("G6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ActivateNext
ActiveWindow.Close
End Sub

--
EW - Analyst


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Referencing date and worksheet tab

The first code worked great! Thanks for the help!
--
EW - Analyst


"Dave Peterson" wrote:

datewks.range("C58").copy
mainwks.range("g6").pastespecial paste:=xlpastevalues

or

mainwks.range("g6").value = datewks.range("C58").value



ewagz wrote:

The date portion worked great! Is there a way to have it paste the data in
the last part of the code to paste special with value only?

'do what you need to do to datewks??
DateWks.Range("C58").Copy _
Destination:=MainWks.Range("G6")

DateWkbk.Close savechanges:=False
--
EW - Analyst

"Dave Peterson" wrote:

Maybe something like this:

Option Explicit
sub testme()

dim MainWks as worksheet
Dim DateCell as range
dim DateWks as worksheet
dim DateWkbk as workbook

set mainwks = thisworkbook.worksheets("Main")
set datecell = mainwks.range("a1")

set datewkbk = Workbooks.Open(Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls")

set datewks = datewkbk.worksheets(cstr(datecell.text))

'do what you need to do to datewks??
datewks.range("a1:b99").copy _
destination:=mainwks.range("x99")

datewkbk.close savechanges:=false

end sub

Untested, but it compiled ok.

ewagz wrote:

I would like to take a main workbook and right a code into my current code
that would look at the date on the main workbook and cross refernce that to
the data workbook. The data workbook already has the tabs named for each day
of the month (1,2,3,4...). I have a main worksheet that has the =now()
producing the date in format dd. How do I make this dynamic so that it will
look at different tabs that corrispond with the current date??
This is the current code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/5/2006 by Eric Wagner
'

'
Workbooks.Open Filename:= _
"C:\Documents and Settings\Name\Desktop\LA Test\LA test.xls"
Sheets("1").Select
ActiveWindow.SmallScroll Down:=13
Range("C58").Select
Selection.Copy
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.ActivateNext
Range("G6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ActivateNext
ActiveWindow.Close
End Sub

--
EW - Analyst

--

Dave Peterson


--

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
Referencing a Worksheet newguy Excel Discussion (Misc queries) 3 December 12th 06 07:31 PM
Date referencing Barry Clark Excel Worksheet Functions 10 June 26th 06 04:42 PM
CountIF() in Worksheet B while referencing cells in Worksheet A jfj3rd Excel Worksheet Functions 3 April 14th 06 11:24 PM
CountIF() in Worksheet B while referencing cells in Worksheet A jfj3rd Excel Worksheet Functions 3 April 14th 06 07:36 PM
Referencing another worksheet rmellison Excel Discussion (Misc queries) 10 September 15th 05 03:07 PM


All times are GMT +1. The time now is 11:53 PM.

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

About Us

"It's about Microsoft Excel"