Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 2 issues really


hi,

Thanks for the feedback - I'm pleased we could help :)

Here's a slight twist on Rick's vba approach using arrays which -may be
slightly- quicker if you have a lot of rows of data to modify.


Code:
--------------------
Option Explicit

Sub ConcatBandC_UsingArrays()
Dim x As Long, LastRow As Long
Dim TempArrB As Variant
Dim TempArrC As Variant
With ActiveSheet
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
With .Range(Cells(2, 2), Cells(LastRow, 2))
'populate temporary arrays with data from the sheet
TempArrB = .Value2
TempArrC = .Offset(0, 1).Value2
'loop through the array & modify it (in memory)
For x = LBound(TempArrB) To UBound(TempArrB)
TempArrB(x, 1) = TempArrB(x, 1) & Format(TempArrC(x, 1), " 00000")
Next x
'write array back to the spreadsheet
.Value2 = TempArrB
End With
End With
End Sub

--------------------


Note that the last action of writing the array back to the range may
(?) be subject to the limitations of copying vba arrays to worksheet
ranges which are discussed in the below links:
'Daily Dose of Excel » Blog Archive » Writing To A Range Using VBA'
(http://tinyurl.com/yhfzqj8)
'XL: Limitations of Passing Arrays to Excel Using Automation'
(http://support.microsoft.com/kb/177991)

Rick, I know you've given a quick solution (like I did in my initial
post) but I think it's important to explicitly define range objects
(even if it is just to the active sheet) because this makes OP's aware
of where the changes will occur/what data will be used - whereas not all
OP's know that the default of "range(..." is to the active sheet esp if
they are also impacting other sheets within the code.

hth
Rob


--
broro183

Rob Brockett. Always learning & the best way to learn is to
experience...
------------------------------------------------------------------------
broro183's Profile: http://www.thecodecage.com/forumz/member.php?userid=333
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=144631

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
TODAY() issues Keyrookie Excel Worksheet Functions 6 August 27th 07 12:48 PM
Issues with VBA Chris Excel Programming 3 November 3rd 06 06:42 PM
C# VBA DLL issues Temporalis Excel Programming 5 October 20th 06 10:49 PM
need help for several issues bandy2000 Excel Programming 2 March 15th 05 02:11 AM
Issues with solver Chris Excel Programming 0 July 16th 04 10:24 PM


All times are GMT +1. The time now is 07:41 AM.

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"