#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 266
Default VBA syntax

I have some code in a macro that was recorded like this:
TableDestination:="[MyWorkbook.xlsm]Sales!R5C1"

I would like to replace Myworkbook.xlsm with "ActiveWorkbook

Is this the syntax:

TableDestination:="[ActiveWorkbook]Reorder!R5C1" ?

OR

TableDestination:="ActiveWorkbook.Reorder!R5C1"

OR something else?

Thanks for any help on this
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default VBA syntax

ActiveWorkbook.Sheets("Sales").Cells(5, 1)

it has to be of the form
workbook.worksheet.range

"dhstein" wrote:

I have some code in a macro that was recorded like this:
TableDestination:="[MyWorkbook.xlsm]Sales!R5C1"

I would like to replace Myworkbook.xlsm with "ActiveWorkbook

Is this the syntax:

TableDestination:="[ActiveWorkbook]Reorder!R5C1" ?

OR

TableDestination:="ActiveWorkbook.Reorder!R5C1"

OR something else?

Thanks for any help on this

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 896
Default VBA syntax

try:

Dim k as String
k = "'[" & ThisWorkbook.Name & "]Reorder'!R5C1"
TableDestination:= k


On 13 Mar, 01:46, dhstein wrote:
I have some code in a macro that was recorded like this: *
TableDestination:="[MyWorkbook.xlsm]Sales!R5C1"

I would like to replace Myworkbook.xlsm with "ActiveWorkbook

Is this the syntax:

TableDestination:="[ActiveWorkbook]Reorder!R5C1" * ?

OR

TableDestination:="ActiveWorkbook.Reorder!R5C1"

OR something else?

Thanks for any help on this


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default VBA syntax

I like to let excel's vba take care of the syntax.

dim DestCell as range
set destcell = workbooks("myworkbook.xlsm").worksheets("sales").c ells(5,1)
or this--it doesn't matter if you use .cells() or .range()
set destcell = workbooks("myworkbook.xlsm").worksheets("sales").r ange("a5")
or
set destcell = activeworkbook.worksheets("sales").range("a5")
or (if you're running from the correct worksheet)
set destcell = activesheet.range("a5")

....tabledestination:=destcell.address(external:=t rue), ...




dhstein wrote:

I have some code in a macro that was recorded like this:
TableDestination:="[MyWorkbook.xlsm]Sales!R5C1"

I would like to replace Myworkbook.xlsm with "ActiveWorkbook

Is this the syntax:

TableDestination:="[ActiveWorkbook]Reorder!R5C1" ?

OR

TableDestination:="ActiveWorkbook.Reorder!R5C1"

OR something else?

Thanks for any help on this


--

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
VB Syntax dhstein Excel Discussion (Misc queries) 6 November 8th 08 09:13 PM
The NOW() syntax Tom Excel Discussion (Misc queries) 3 January 4th 08 04:10 PM
IRR Syntax Bruce Excel Worksheet Functions 1 July 13th 07 09:02 PM
Help with Syntax Steve Excel Discussion (Misc queries) 2 June 21st 07 06:52 PM
VBA syntax Sunantoro Excel Discussion (Misc queries) 1 September 21st 05 03:19 AM


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