PC Review


Reply
Thread Tools Rate Thread

How to display the active row number

 
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      10th Jul 2007
I have the following code:
------------
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


'replace and add cell reference
newRng.Cells.Replace What:="=SUM(#REF!)",
Replacement:="='" & _
Sh.Name & "'!G" & ActiveCell.Row, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False


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

Set newRng = newRng.Offset(0, 1)


End If


Next
------
Basically it copies the column G from every worksheets to another
worksheet. On the new worksheet I want to replace the cells value to
the actual worksheet/cell number

How do i add the actual row number to ='wsName'!G

Using ActiveCell.Row adds 1 to all the cells. I know of Row() but I
dont know how to use Row() in VB.

Thank you,

Sharon

 
Reply With Quote
 
 
 
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      10th Jul 2007
Here's the example:

On the new worksheet where column G is being copied, the row number is
listed on the left, I want it to display like this:

1 Wkly
2 Total
3
4 ='wsName'!G4
5 ='wsName'!G5
6 ='wsName'!G6
7 ='wsName'!G7

but with the code above, i get this:
1 Wkly
2 Total
3
4 ='wsName'!G1
5 ='wsName'!G1
6 ='wsName'!G1
7 ='wsName'!G1

wsName is the worksheet's name where column G is being copied to new
new worksheet above.

I will continue to search but if anyone knows how to solve this
problem, I greatly appreciate the help. Thanks, Sharon

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      11th Jul 2007
newRng.Cells.Replace What:="=SUM(#REF!)",
Replacement:="='" & _
Sh.Name & "'!G" & ActiveCell.Row, _
LookAt:=xlPart, SearchOrder:=xlByRows,
MatchCase:=False


becomes
Dim newRng1 as Range

set newRng1 = newRng.EntireColumn.SpecialCells(xlFormulas)
newRng1.Formula = "='" & shName & "'!" & newRng1(1).Address(0,0)

--
Regards,
Tom Ogilvy

"(E-Mail Removed)" wrote:

> Here's the example:
>
> On the new worksheet where column G is being copied, the row number is
> listed on the left, I want it to display like this:
>
> 1 Wkly
> 2 Total
> 3
> 4 ='wsName'!G4
> 5 ='wsName'!G5
> 6 ='wsName'!G6
> 7 ='wsName'!G7
>
> but with the code above, i get this:
> 1 Wkly
> 2 Total
> 3
> 4 ='wsName'!G1
> 5 ='wsName'!G1
> 6 ='wsName'!G1
> 7 ='wsName'!G1
>
> wsName is the worksheet's name where column G is being copied to new
> new worksheet above.
>
> I will continue to search but if anyone knows how to solve this
> problem, I greatly appreciate the help. Thanks, Sharon
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      11th Jul 2007
this assumed that newRng was is column G. If it isn't, then here is a
modification


Dim newRng1 as Range
Dim r as Range
set newRng1 = newRng.EntireColumn.SpecialCells(xlFormulas)
set r = newRng1.parent.Cells(newRng1(1).row,"G")
newRng1.Formula = "='" & shName & "'!" & r.Address(0,0)

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote:

> newRng.Cells.Replace What:="=SUM(#REF!)",
> Replacement:="='" & _
> Sh.Name & "'!G" & ActiveCell.Row, _
> LookAt:=xlPart, SearchOrder:=xlByRows,
> MatchCase:=False
>
>
> becomes
> Dim newRng1 as Range
>
> set newRng1 = newRng.EntireColumn.SpecialCells(xlFormulas)
> newRng1.Formula = "='" & shName & "'!" & newRng1(1).Address(0,0)
>
> --
> Regards,
> Tom Ogilvy
>
> "(E-Mail Removed)" wrote:
>
> > Here's the example:
> >
> > On the new worksheet where column G is being copied, the row number is
> > listed on the left, I want it to display like this:
> >
> > 1 Wkly
> > 2 Total
> > 3
> > 4 ='wsName'!G4
> > 5 ='wsName'!G5
> > 6 ='wsName'!G6
> > 7 ='wsName'!G7
> >
> > but with the code above, i get this:
> > 1 Wkly
> > 2 Total
> > 3
> > 4 ='wsName'!G1
> > 5 ='wsName'!G1
> > 6 ='wsName'!G1
> > 7 ='wsName'!G1
> >
> > wsName is the worksheet's name where column G is being copied to new
> > new worksheet above.
> >
> > I will continue to search but if anyone knows how to solve this
> > problem, I greatly appreciate the help. Thanks, Sharon
> >
> >

 
Reply With Quote
 
azu_daioh@yahoo.com
Guest
Posts: n/a
 
      11th Jul 2007
Thank you so much Tom!!! You're a life saver. Now, I just need to
understand what each line means/do but Im sure online help will be
able to help me.

Thanks again.
Sharon

This one works.

> Dim newRng1 as Range
> Dim r as Range
> set newRng1 = newRng.EntireColumn.SpecialCells(xlFormulas)
> set r = newRng1.parent.Cells(newRng1(1).row,"G")
> newRng1.Formula = "='" & shName & "'!" & r.Address(0,0)
>
> --
> Regards,
> Tom Ogilvy




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get number of currently active slide Clevedog Microsoft Powerpoint 0 7th Jul 2008 10:06 PM
Any way to display cardinal number from a number field? =?Utf-8?B?bmF0ZSBtYXJ0aW5lei13YXltYW4=?= Microsoft Access Reports 1 11th Apr 2006 09:03 PM
Make auto number display year and an increasing number (yy-###) =?Utf-8?B?bWV0cnVuZWM4Ng==?= Microsoft Access 4 26th Jan 2006 09:00 PM
VBA question - Getting las active row number ajliaks Microsoft Excel Programming 1 16th Apr 2004 07:43 PM
Number of active sheets Michael Kuhn Microsoft Excel Misc 1 2nd Feb 2004 03:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:04 PM.