Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default how to use reference cell in VB?

I have this code that works great on one workbook but I have to modify
it for another workbook.

Here's the code I have/want to modify:
----------------
Dim newRng As Range
Dim newWs As Worksheet
Dim rng As Range

Set newWs = Worksheets("GTOTAL")
Set aWs = Worksheets(1)
Set bWs = Worksheets(2)
Set newRng = newWs.Range("C:C")

For Each Sh In ActiveWorkbook.Worksheets
If Sh.Name < newWs.Name And Sh.Name < aWs.Name And Sh.Name
< bWs.Name Then

Set rng = Nothing
On Error Resume Next
Set rng = Sh.Range("lblWTotal")
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Sheet " & Sh.Name & " does not contain
lblWTotal"
Else
Sh.Range("lblWTotal").Value = Sh.Name
End If


Sh.Range("G:G").Copy
newRng.PasteSpecial xlPasteValues
newRng.PasteSpecial xlPasteFormats

Sh.Range("lblWTotal").Value = "Wkly"


Set newRng = newRng.Offset(0, 1)
End If
Next
-------------

Now instead of pasting the value and formats, I would like it to paste
the a reference of the cell it copied.

For example if the first SH is 205
GTOTAL!C4 = 205!G4.
GTOTAL!C5 = 205!G5

then on next SH = 206
GTOTAL!D4 = 206!G4
GTOTAL!D5 = 206!G5

and so on

Is this possible? I tried searching and using the codes I find here
and could not make it work. Please help. Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default how to use reference cell in VB?


GTOTAL!C4 = 205!G4.
GTOTAL!C5 = 205!G5

then on next SH = 206
GTOTAL!D4 = 206!G4
GTOTAL!D5 = 206!G5

and so on

Is this possible? I tried searching and using the codes I find here
and could not make it work. Please help. Thank you.


I use
Cells.Replace What:="OtherSheet!", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False

after .PasteSpecial

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
Changing sheet reference to cell reference TeeJay Excel Worksheet Functions 3 October 19th 07 11:50 AM
Formulas that reference cells that reference another cell Andrea Excel Discussion (Misc queries) 7 October 19th 06 08:14 AM
absolute cell reference A spreadsheet cell reference that does no help Excel Discussion (Misc queries) 1 January 18th 06 06:56 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


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

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"