Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy Value Of Last Cell


Hi:

I'm modifying someone else's macro (which works fine) to instead of
inserting the cheet name to sort it, it would insert the value of the
last cell in column B

this is part of that macro

Sub SortALLSheets()
'
Dim WB As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim cSheets As Integer
Dim sSheets() As String
Dim i As Integer
'
Set WB = ActiveWorkbook 'get true array dimension
cSheets = WB.Sheets.Count
ReDim sSheets(1 To cSheets) 'fill array with worksheet names
'
For i = 1 To cSheets
'sSheets(i) = WB.Sheets(i).Name
sSheets(i) = Range("B65536").End(xlUp).Select ------HERE
'Selection.Copy
Next
Set ws = WB.Worksheets.Add 'create new sheet and put names in first
column
'
For i = 1 To cSheets
ws.Cells(i, 1).Value = sSheets(i)
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Copy Value Of Last Cell

Just use

For i = 1 To cSheets
sSheets(i) = Range("B65536").End(xlUp).Value
Next


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"halem2" wrote in
message ...

Hi:

I'm modifying someone else's macro (which works fine) to instead of
inserting the cheet name to sort it, it would insert the value of the
last cell in column B

this is part of that macro

Sub SortALLSheets()
'
Dim WB As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim cSheets As Integer
Dim sSheets() As String
Dim i As Integer
'
Set WB = ActiveWorkbook 'get true array dimension
cSheets = WB.Sheets.Count
ReDim sSheets(1 To cSheets) 'fill array with worksheet names
'
For i = 1 To cSheets
'sSheets(i) = WB.Sheets(i).Name
sSheets(i) = Range("B65536").End(xlUp).Select ------HERE
'Selection.Copy
Next
Set ws = WB.Worksheets.Add 'create new sheet and put names in first
column
'
For i = 1 To cSheets
ws.Cells(i, 1).Value = sSheets(i)
Next



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Copy Value Of Last Cell

sSheets(i) = Range("B65536").End(xlUp).Value

rather than

sSheets(i) = Range("B65536").End(xlUp).Select

--
Regards,
Tom Ogilvy


"halem2" wrote:


Hi:

I'm modifying someone else's macro (which works fine) to instead of
inserting the cheet name to sort it, it would insert the value of the
last cell in column B

this is part of that macro

Sub SortALLSheets()
'
Dim WB As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim cSheets As Integer
Dim sSheets() As String
Dim i As Integer
'
Set WB = ActiveWorkbook 'get true array dimension
cSheets = WB.Sheets.Count
ReDim sSheets(1 To cSheets) 'fill array with worksheet names
'
For i = 1 To cSheets
'sSheets(i) = WB.Sheets(i).Name
sSheets(i) = Range("B65536").End(xlUp).Select ------HERE
'Selection.Copy
Next
Set ws = WB.Worksheets.Add 'create new sheet and put names in first
column
'
For i = 1 To cSheets
ws.Cells(i, 1).Value = sSheets(i)
Next

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy Value Of Last Cell


I have tried that but it copies the same value to th new sheet instea
of the actual value of the cells in every sheet. It's not transferrin
the values properly. Any other thoughts

--
halem
-----------------------------------------------------------------------
halem2's Profile: http://www.excelforum.com/member.php...nfo&userid=993
View this thread: http://www.excelforum.com/showthread.php?threadid=55986

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
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
I copy a formula and the results copy from the original cell brooklynsd Excel Discussion (Misc queries) 1 June 23rd 07 01:35 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


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