Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Enter a constant into Ten Workbooks

In my folder My Documents\Test
I have ten xls files, nothing else. They are not Open
In Cell C10 of Sheet1 of each file
I'd like to run a macro and it overwrite cell C10 with a number from an
Input Box.
Can this be done?

Thanks in advance,,,


  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Enter a constant into Ten Workbooks

Sub WriteToMany()
Const myPath = "My Documents\Test\"
Dim rep As String
Dim wName As String
Dim wBook As Workbook

rep = InputBox("Enter new value to
overwrite", "Overwrite in all files")
If rep = "" Then Exit Sub

Application.ScreenUpdating = False
wName = Dir(myPath & "*.xls")

Do While wName < ""
Set wBook = Workbooks.Open(myPath & wName)
wBook.Worksheets("Sheet1").Range("C10").Value = rep
wBook.Close SaveChanges:=True
wName = Dir()
Loop
Set wBook = Nothing

Application.ScreenUpdating = True
End Sub

Kevin Beckham

-----Original Message-----
In my folder My Documents\Test
I have ten xls files, nothing else. They are not Open
In Cell C10 of Sheet1 of each file
I'd like to run a macro and it overwrite cell C10

with a number from an
Input Box.
Can this be done?

Thanks in advance,,,


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Enter a constant into Ten Workbooks

Thank you so much,, This is awesome...
JMay

wrote in message
...
Sub WriteToMany()
Const myPath = "My Documents\Test\"
Dim rep As String
Dim wName As String
Dim wBook As Workbook

rep = InputBox("Enter new value to
overwrite", "Overwrite in all files")
If rep = "" Then Exit Sub

Application.ScreenUpdating = False
wName = Dir(myPath & "*.xls")

Do While wName < ""
Set wBook = Workbooks.Open(myPath & wName)
wBook.Worksheets("Sheet1").Range("C10").Value = rep
wBook.Close SaveChanges:=True
wName = Dir()
Loop
Set wBook = Nothing

Application.ScreenUpdating = True
End Sub

Kevin Beckham

-----Original Message-----
In my folder My Documents\Test
I have ten xls files, nothing else. They are not Open
In Cell C10 of Sheet1 of each file
I'd like to run a macro and it overwrite cell C10

with a number from an
Input Box.
Can this be done?

Thanks in advance,,,


.



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
Macro to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 PM
Enter multiple numbers in a cell so total shows when enter keypres newbie Excel Worksheet Functions 2 August 19th 07 12:23 PM
Enter info in one sheet, auto enter in another based on one field The BusyHighLighter[_2_] New Users to Excel 1 August 1st 07 10:54 PM
Constant loan payments vs. constant payments of principal lalli945 Excel Worksheet Functions 3 December 20th 06 10:33 PM
Constant between workbooks Krmsy Excel Discussion (Misc queries) 1 January 18th 06 03:43 PM


All times are GMT +1. The time now is 01:07 PM.

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"