#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 226
Default Cell Ref question

Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 419
Default Cell Ref question

Roger,

Maybe something like this would work (haven't tested it):

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

'ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value
we.Cells(irow, 12).Formula = "='" & ActiveSheet.Name & "'!H5"

Worksheets("sheet1").Select

End Sub



HTH,


Conan





"Roger" wrote in message
...
Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I
want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I
want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cell Ref question

You could record a macro when you do
Edit|copy
followed by Edit|paste special|paste Link

Or you could just build the formula yourself:

ws.Cells(irow, 12).Formula _
= "=" & ActiveSheet.Range("h5").Address(external:=True)

Roger wrote:

Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cell Ref question

It would work nicely if the sheets weren't in different workbooks.

Conan Kelly wrote:

Roger,

Maybe something like this would work (haven't tested it):

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

'ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value
we.Cells(irow, 12).Formula = "='" & ActiveSheet.Name & "'!H5"

Worksheets("sheet1").Select

End Sub

HTH,

Conan

"Roger" wrote in message
...
Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I
want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I
want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 226
Default Cell Ref question

Hi Dave,

That works just terrific €“ Thanks.

Say, can I tap your brain one last time? How can I expand on that formula
to add nothing if cell H5 is empty. Right now it links and puts the value in
the front page, but I dont want to show a value in the H5 has nothing in its
cell?

Thanks so much for your review and thoughts - Roger


"Dave Peterson" wrote:

You could record a macro when you do
Edit|copy
followed by Edit|paste special|paste Link

Or you could just build the formula yourself:

ws.Cells(irow, 12).Formula _
= "=" & ActiveSheet.Range("h5").Address(external:=True)

Roger wrote:

Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cell Ref question

You have a couple of choices...

Either use a different formula that makes the cell look blank if that cell is
empty:

Option Explicit
Sub WritetoMainPage()

Dim irow As Long
Dim myAddr As String
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

myAddr = ActiveSheet.Range("h5").Address(external:=True)
ws.Cells(irow, 12).Formula _
= "=if(" & myAddr & " = """",""""," & myAddr & ")"

ws.Select

End Sub

Or you could avoid populating the cell with any formula:

Option Explicit
Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Dim myAddr As String

Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

With ActiveSheet.Range("h5")
If IsEmpty(.Value) Then
'do nothing
'or empty that cell???
'ws.Cells(irow, 12).ClearContents
Else
myAddr = .Address(external:=True)
ws.Cells(irow, 12).Formula _
= "=if(" & myAddr & " = """",""""," & myAddr & ")"
End If
End With

ws.Select

End Sub

Roger wrote:

Hi Dave,

That works just terrific €“ Thanks.

Say, can I tap your brain one last time? How can I expand on that formula
to add nothing if cell H5 is empty. Right now it links and puts the value in
the front page, but I dont want to show a value in the H5 has nothing in its
cell?

Thanks so much for your review and thoughts - Roger

"Dave Peterson" wrote:

You could record a macro when you do
Edit|copy
followed by Edit|paste special|paste Link

Or you could just build the formula yourself:

ws.Cells(irow, 12).Formula _
= "=" & ActiveSheet.Range("h5").Address(external:=True)

Roger wrote:

Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 226
Default Cell Ref question

Both worked just great.

Thanks once again for all your help - Roger

"Dave Peterson" wrote:

You have a couple of choices...

Either use a different formula that makes the cell look blank if that cell is
empty:

Option Explicit
Sub WritetoMainPage()

Dim irow As Long
Dim myAddr As String
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

myAddr = ActiveSheet.Range("h5").Address(external:=True)
ws.Cells(irow, 12).Formula _
= "=if(" & myAddr & " = """",""""," & myAddr & ")"

ws.Select

End Sub

Or you could avoid populating the cell with any formula:

Option Explicit
Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Dim myAddr As String

Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

With ActiveSheet.Range("h5")
If IsEmpty(.Value) Then
'do nothing
'or empty that cell???
'ws.Cells(irow, 12).ClearContents
Else
myAddr = .Address(external:=True)
ws.Cells(irow, 12).Formula _
= "=if(" & myAddr & " = """",""""," & myAddr & ")"
End If
End With

ws.Select

End Sub

Roger wrote:

Hi Dave,

That works just terrific Γ’‚¬€œ Thanks.

Say, can I tap your brain one last time? How can I expand on that formula
to add nothing if cell H5 is empty. Right now it links and puts the value in
the front page, but I donΓ’‚¬„’t want to show a value in the H5 has nothing in its
cell?

Thanks so much for your review and thoughts - Roger

"Dave Peterson" wrote:

You could record a macro when you do
Edit|copy
followed by Edit|paste special|paste Link

Or you could just build the formula yourself:

ws.Cells(irow, 12).Formula _
= "=" & ActiveSheet.Range("h5").Address(external:=True)

Roger wrote:

Good Afternoon,

I have a macro that is writing from one workbook to another. After it has
finished opening and writing it's initial data, it calls this macro and
writes a special cell value to the front page. Though this works fine, I want
it to be a cell reference (linked value) vs. static.

Ive tried a couple ways unsuccessfully and was wondering if you might have
some ideas on how to accomplish this.

Thank you - Roger

Sub WritetoMainPage()

Dim irow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

irow = ws.Cells(1, 12) _
.End(xlDown).Offset(1, 0).Row

ws.Cells(irow, 12) = ActiveSheet.Range("h5").Value <<<This works but I want
a cell ref (link) vs. static value

Worksheets("sheet1").Select

End sub
Was this post helpful to you?

Why should I

--

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
Conditional Formatting question (if cell = 0, wrap cell in quotes) Mo2 New Users to Excel 6 May 11th 07 11:06 PM
Cell question Steve Excel Worksheet Functions 2 July 4th 06 09:53 AM
Excel cell question hwank1 Excel Discussion (Misc queries) 5 June 12th 06 08:02 PM
Yet another cell color question. smoore Excel Discussion (Misc queries) 5 January 30th 06 11:06 PM
empty cell question D Excel Worksheet Functions 4 July 28th 05 09:25 AM


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