ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column Counting (https://www.excelbanter.com/excel-programming/328825-column-counting.html)

lawson

Column Counting
 
Hello

i have a spreadsheet that upon opening, it counts all the spreadsheets (n)
that are also open and are named inclusively between 1 and 25. it then enters
the values 1, 2, 3....n in column A5:A25.

thanks

Lawson

Bob Phillips[_6_]

Column Counting
 
and the question is ...?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"lawson" wrote in message
...
Hello

i have a spreadsheet that upon opening, it counts all the spreadsheets (n)
that are also open and are named inclusively between 1 and 25. it then

enters
the values 1, 2, 3....n in column A5:A25.

thanks

Lawson




Alok

Column Counting
 
Hi,

Just need some clarifications to answer your question. Do you mean that the
code should record the names of all the open workbooks in A5:A25? Are they
named 1.xls, 2.xls etc? Also you probably meant A1:A25 if all 25 were open
and their names had to be recorded?

Alok

"lawson" wrote:

Hello

i have a spreadsheet that upon opening, it counts all the spreadsheets (n)
that are also open and are named inclusively between 1 and 25. it then enters
the values 1, 2, 3....n in column A5:A25.

thanks

Lawson


lawson

Column Counting
 
hi back!

no, i dont want it to record the names. i want it to count the spreadsheets
if and only if they're names are 1.xls, 2.xls...25.xls, then enter the values
1 through n in (what i should have typed the first time) a5:a:30. if there
are only 5 spreadsheets open (ie 1.xls, 2.xls...5.xls) then it starts in a5
and enters 1, 2 in a6,...5 in a9

thanks a million

"Alok" wrote:

Hi,

Just need some clarifications to answer your question. Do you mean that the
code should record the names of all the open workbooks in A5:A25? Are they
named 1.xls, 2.xls etc? Also you probably meant A1:A25 if all 25 were open
and their names had to be recorded?

Alok

"lawson" wrote:

Hello

i have a spreadsheet that upon opening, it counts all the spreadsheets (n)
that are also open and are named inclusively between 1 and 25. it then enters
the values 1, 2, 3....n in column A5:A25.

thanks

Lawson


Alok

Column Counting
 
Hi

Copy this code in the Workbook_Open event of your workbook
You may need to refine this code as needed

Dim wb As Workbook
Dim s$, i%
For Each wb In Workbooks
If Not wb Is ThisWorkbook Then
On Error Resume Next
i = Val(Mid$(wb.Name, 1, InStr(wb.Name, ".xls") - 1))
If i = 1 And i <= 25 Then
Sheet1.Cells(5 + i - 1, 1).Value = i
End If
End If
Next wb

HTH

Alok Joshi

"lawson" wrote:

hi back!

no, i dont want it to record the names. i want it to count the spreadsheets
if and only if they're names are 1.xls, 2.xls...25.xls, then enter the values
1 through n in (what i should have typed the first time) a5:a:30. if there
are only 5 spreadsheets open (ie 1.xls, 2.xls...5.xls) then it starts in a5
and enters 1, 2 in a6,...5 in a9

thanks a million

"Alok" wrote:

Hi,

Just need some clarifications to answer your question. Do you mean that the
code should record the names of all the open workbooks in A5:A25? Are they
named 1.xls, 2.xls etc? Also you probably meant A1:A25 if all 25 were open
and their names had to be recorded?

Alok

"lawson" wrote:

Hello

i have a spreadsheet that upon opening, it counts all the spreadsheets (n)
that are also open and are named inclusively between 1 and 25. it then enters
the values 1, 2, 3....n in column A5:A25.

thanks

Lawson



All times are GMT +1. The time now is 09:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com