Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2013, 06:36 PM
Registered User
 
Join Date: Aug 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Insert <start> and <finish> between data

Hi,

Is it possible using VBA to insert <Start> and <Finish> before and after a set of data.

Example:

Beginning data

71723,121222010,EXAPLECOMPANY,2-13-2013,
71723,121222010,EXAPLECOMPANY,2-13-2013,
71721,121221142,EXAPLECOMPANY,2-13-2013,
71718,121234503,EXAPLECOMPANY,2-13-2013,
71718,121234503,EXAPLECOMPANY,2-13-2013,
71720,121238748,EXAPLECOMPANY2-13-2013,

After VBA

<Start>
71723,121222010,EXAPLECOMPANY,2-13-2013,
71723,121222010,EXAPLECOMPANY,2-13-2013,
<Finish>
<Start>
71721,121221142,EXAPLECOMPANY,2-13-2013,
<Finish>
<Start>
71718,121234503,EXAPLECOMPANY,2-13-2013,
71718,121234503,EXAPLECOMPANY,2-13-2013,
<Finish>
<Start>
71720,121238748,EXAPLECOMPANY2-13-2013,
<Finish>

Thanks for any help or advice,

David
 
Old March 3rd, 2013, 10:15 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

It is very much doable. The crude way is to read through the values in column A (I suppose) and whenever the value changes add the Tags.

Here is a place to start

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips &amp; Tricks (http://www.vbadud.blogspot.com)
 
Old March 6th, 2013, 10:47 AM
Registered User
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If your data is consistently in this format and you can parse working data in the columns next to the original data, then try this (with original data in A1:A6 cells and second delimited data point being the item monitored for change):


Sub Bracketing()

Range("A1").Select
Selection.EntireRow.Insert
ActiveCell.FormulaR1C1 = "<Start>"
Range("A2:A7").Select
Selection.Copy
Range("B2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("B2"), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Comma:=True, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), TrailingMinusNumbers:=True
Range("C3").Select
Do While Len(ActiveCell.Formula) > 0
If ActiveCell.Formula = ActiveCell.Offset(-1, 0).Formula Then
ActiveCell.Offset(1, 0).Select
Else
Selection.EntireRow.Insert
ActiveCell.Offset(0, -2).FormulaR1C1 = "<Finish>"
ActiveCell.Offset(1, 0).Select
Selection.EntireRow.Insert
ActiveCell.Offset(0, -2).FormulaR1C1 = "<Start>"
ActiveCell.Offset(2, 0).Select
End If
Loop
ActiveCell.Offset(0, -2).FormulaR1C1 = "<Finish>"
Range("B1:E" & ActiveCell.Row).Clear
Range("A1").Select
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 8: <asp:image> inside <a> & ext.CSS (pg. 274) epc BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 July 12th, 2008 04:37 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
<marquee><b>About CHAT App. in PHP4</b></marquee> Ramkrishna PHP How-To 1 September 11th, 2004 07:01 AM
<STRONG> vs <B> and <EM> vs <I> anshul HTML Code Clinic 12 September 1st, 2004 05:22 PM
the book <<Data-Centric.net programing with c#>> jamxx All Other Wrox Books 0 November 18th, 2003 10:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.