Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.dotnet.languages.vb,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Is there a write-multi-cell-at-once function in VBS for Excel?

As well known I can write into an Excel cell a certain value with in a VBS script with e.g.

objWorksheet.Cells(2, 5).Value = 55

Can I write the value 55 into multiple cells at once?
Imagine I want to write in all cells 2,5 .... 2,37 the value 55.
Do I really have to iterate through all cells individually or is there a function like

objWorksheet.multiCells((2,5),(2,37)).Value = 55

?

Tony

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Is there a write-multi-cell-at-once function in VBS for Excel?

On 21 Jun., 00:03, (Tony Bansten) wrote:
As well known I can write into an Excel cell a certain value with in a VBS script with e.g.

objWorksheet.Cells(2, 5).Value = 55

Can I write the value 55 into multiple cells at once?
Imagine I want to write in all cells * 2,5 .... 2,37 the value 55.
Do I really have to iterate through all cells individually or is there a function like

objWorksheet.multiCells((2,5),(2,37)).Value = 55

?

Tony


Hi Tony

Look at this:

objWorksheet.Range("B5:B37").Value = 55
objWorksheet.Range(Cells(2, 5), Cells(2, 37)).Value = 55

Regards,
Per
  #4   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.dotnet.languages.vb,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Is there a write-multi-cell-at-once function in VBS for Excel?

No iteration is needed:

Sub tony()
Set objWorksheet = ActiveSheet
objWorksheet.Range(Cells(2, 5), Cells(2, 37)).Value = 55
End Sub

You only need a loop if you want individual values in individual cells, and
by using arrays properly, maybe not even then.
--
Gary''s Student - gsnu2007j


"Tony Bansten" wrote:

As well known I can write into an Excel cell a certain value with in a VBS script with e.g.

objWorksheet.Cells(2, 5).Value = 55

Can I write the value 55 into multiple cells at once?
Imagine I want to write in all cells 2,5 .... 2,37 the value 55.
Do I really have to iterate through all cells individually or is there a function like

objWorksheet.multiCells((2,5),(2,37)).Value = 55

?

Tony


  #5   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.dotnet.languages.vb,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is there a write-multi-cell-at-once function in VBS for Excel?

It's probably better to fully qualify those ranges in case objWorksheet isn't
the activesheet.

with objWorksheet
.Range(.Cells(2, 5), .Cells(2, 37)).Value = 55
end with

or

objWorksheet.Range("E2").resize(1,33).Value = 55


Gary''s Student wrote:

No iteration is needed:

Sub tony()
Set objWorksheet = ActiveSheet
objWorksheet.Range(Cells(2, 5), Cells(2, 37)).Value = 55
End Sub

You only need a loop if you want individual values in individual cells, and
by using arrays properly, maybe not even then.
--
Gary''s Student - gsnu2007j

"Tony Bansten" wrote:

As well known I can write into an Excel cell a certain value with in a VBS script with e.g.

objWorksheet.Cells(2, 5).Value = 55

Can I write the value 55 into multiple cells at once?
Imagine I want to write in all cells 2,5 .... 2,37 the value 55.
Do I really have to iterate through all cells individually or is there a function like

objWorksheet.multiCells((2,5),(2,37)).Value = 55

?

Tony



--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Is there a write-multi-cell-at-once function in VBS for Excel?

Check your other post and make sure you qualify all those range objects
(.range() and .cells()).

Tony Bansten wrote:

As well known I can write into an Excel cell a certain value with in a VBS script with e.g.

objWorksheet.Cells(2, 5).Value = 55

Can I write the value 55 into multiple cells at once?
Imagine I want to write in all cells 2,5 .... 2,37 the value 55.
Do I really have to iterate through all cells individually or is there a function like

objWorksheet.multiCells((2,5),(2,37)).Value = 55

?

Tony


--

Dave Peterson
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
Is there a write-multi-cell-at-once function in VBS for Excel? Tony Bansten Excel Discussion (Misc queries) 2 June 21st 08 12:14 AM
Write a function in a split cell. blanca Excel Programming 1 April 3rd 08 08:55 PM
How do I write the IF function to reflect the result in one cell? AMBO Excel Worksheet Functions 8 October 24th 06 07:32 PM
how can I paste multi-line/multi-paragraph data into ONE cell? Theano Excel Discussion (Misc queries) 3 June 7th 05 01:10 PM
Write a function call into an Excel cell from VBA Conceptor Excel Programming 2 September 10th 03 05:41 PM


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

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"