#### MultiLine Code Builder, Need Help to Clean Code:

My end goal is to create multi-line code that I can paste into VBE.
Currently I'm pasting code like this...

If Worksheets("vessel").Cells(CurVesl,8).Value Then
Else
frmVesselLog.DTPICKER1.value = Worksheets("vessel").Cells(CurVesl,11).Value
End IF

For example Column D is:If Worksheets("vessel").Cells(CurVesl,8).Value Then
Column E is : Else
Column F is: frmVesselLog.DTPICKER1.value =
Worksheets("vessel").Cells(CurVesl,11).Value
Column G: End IF

Column H is
row1 If Worksheets("vessel").Cells(CurVesl,8).Value Then
row2 Else
row 3 frmVesselLog.DTPICKER1.value =
Worksheets("vessel").Cells(CurVesl,11).Value
row 4 End IF

IS there a better way/faster way, maybe highlight all the column I want to
create into a multiline code to paste?

I'd appreciate any help to 1-make this a simple process, as sometime I have
3 columns, sometimes 4, sometimes 6, just depends.

Code below:

Sub Create_MultiLine_Code()

Dim DestRow As Integer
Dim Row As Integer

Dim strA As String
Dim strB As String
Dim strC As String
Dim strD As String
Dim ColStrA As Integer
Dim ColStrB As Integer
Dim ColStrC As Integer
Dim ColStrDest As Integer
Dim DestCol As Integer

Const strConst As String = "End Sub" 'Last Line of Text

Row = 1 'Place to Start
DestRow = Row 'Row to Start
DestCol = 8 'Place for Text to end up in

ActiveSheet.Cells(1, DestCol).Activate

Select Case MsgBox("WIll Overwrite all Data in Column #" & DestCol _
& vbCrLf & "Are You Sure?" _
, vbYesNo Or vbQuestion Or vbDefaultButton1, "")

Case vbYes
GoTo EndSelect2
Case vbNo
Exit Sub
End Select

EndSelect2:

Do Until IsEmpty(Cells(Row, 1))

strA = ThisWorkbook.ActiveSheet.Cells(Row, 3).Value 'First Line of Text d
strB = ThisWorkbook.ActiveSheet.Cells(Row, 6).Value 'Second Line of Text j
strC = ThisWorkbook.ActiveSheet.Cells(Row, 7).Value 'Third Line of Text k
' strD = ThisWorkbook.ActiveSheet.Cells(Row, 6).Value 'Third Line of Text f

ThisWorkbook.ActiveSheet.Cells(DestRow, DestCol).Value = strA
ThisWorkbook.ActiveSheet.Cells(DestRow + 1, DestCol).Value = strB
ThisWorkbook.ActiveSheet.Cells(DestRow + 2, DestCol).Value = strC
' ThisWorkbook.ActiveSheet.Cells(DestRow + 3, DestCol).Value = strD

DestRow = DestRow + 3 'I change this depending on the code
Row = Row + 1
Loop

End Sub

 0
Utf
11/18/2009 4:40:14 PM
excel.programming 6508 articles. 2 followers.

0 Replies
458 Views

Similar Articles

[PageSpeed] 12

Similar Artilces:

Error Code 2908 with "Fix It"
I tried to install the "Fix It" for the windows shell vulnerability at this link: http://support.microsoft.com/kb/2286198 I get an error message: "The installer has encountered an unexpected error installing this package. The error code is 2908." I had the same problem when I tried to install the Help Center vulnerability "Fix It" a few weeks ago. Any ideas what may be wrong? Thanks, MM MM wrote: > I tried to install the "Fix It" for the windows shell vulnerability > at this link: > > http://support.microsoft....

Need help to find Values after from
This what a snippit of what my field COMMENT looks like. I would like to be able to get the difference of the from to Thanks for any help. 00033300718160: from $86.990 to$91.550 033300611072: from $25.650 to$25.450 050545220203: from $4.250 to$4.250 First Value can be calculated with Val(Mid([Comments],Instr(1,[Comments],"from $",1)+6)) Second value can be calculated with Val(Mid([Comments],Instr(1,[Comments],"to$",1)+3)) Difference is computed by subtracting the two values. As long as Comments is not null I think this should work for you. It does rely on the dat...

Syntax help
I would value help with below. The first part is what I want to do and what is there works fine. However because of the procedure where locations are variable eg Cells (n, ccount) etc I need to use the syntax on the second procedure and I am unsure of how to enter this and would appreciate any guidance. Graham Range("AF1:AG10").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AF14:AG14"), Unique:=True Range(cells(1,32),cells(9,33)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range(Cells(13,32),cells(13,33)), Unique:=True n=4 ncount=4 c...

Looking for WinSNMP sample code
I'm looking for sample code for WinSNMP. Can someone please tell me where to get them? Thanks, ...

multiline treectrl
Hello, How can I create multiline item of treectrl? Thanks MT Multiline tree ctrls can be done using custom drawing and CTreeCtrl, but are problematic if you allow the user to edit labels, and sometime scrolling is an issue. This might be a good alternative http://www.codeproject.com/treectrl/StaticTreeControl.asp AliR. "mt" <marto@vp.pl> wrote in message news:dqp3t6$ef0$1@nemesis.news.tpi.pl... > Hello, > How can I create multiline item of treectrl? > Thanks > MT Do you mean multiple selections: http://www.codeproject.com/treectrl/MultiSelect_DragImage.asp ...

I had written before about a patch with info as follows. Also, I did call Symantec and they do not know what I am talking about and cannot help me...in the interim, I am not getting all my mail.. "Symantec has fixed an embarrassing flaw in its Norton Internet Security 2003 suite that wrongly deleted email before it hit a user's inbox. When email was deleted, users received a message that read "Symantec Email Proxy Deleted Message". The flaw was first detected 14 October and Symantec began issuing a patch for the problem last week, said Symantec UK company spokesperson Kath...

Code to add wroksheets to a workbook
Hi I have a 2 sheet workbook, and 2 questions about it. :) 1) If I input a (whole) number into cell C3 on Sheet1 ("Main"), I want Excel to create that number of copies of sheet 2. EG, input 2, and I end up with one "Main" sheet and identical sheets which are the original sheet 2 and 2 copies. I've played around some code, but just keep getting errors. 2) The other question is that I have the following code in the 'This Workbook' module: Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) ActiveSheet.Name = Range("AD...

FindFirstFile() problem. Need Help!!! THANKS!!!
When i run code below: WIN32_FIND_DATA FileData; HANDLE hFile = FindFirstFile("\\HardDisk\\be\\bin\\setting\\1.dat", &FileData); DWORD r = GetLastError(); error value r return #3 ERROR_PATH_NOT_FOUND. But when i run code in another class the hFile will return OK. The calss we use is a base class, each Dialog will public from this base class "CBaseDlg.h" CBaseDlg(UINT nIDTemplate, CWnd* pParentWnd); virtual ~CBaseDlg(); "CBaseDlg.cpp" CBaseDlg::CBaseDlg(UINT nIDTemplate, CWnd* pParentWnd) { AFX_ZERO_INIT_OBJECT(CWnd); m_pParentWnd = pParentWnd; m_lpszT...

Lowering security when Help files don't open.
I just learned something today while, again, not being able to bring up Word's Help files. According to the automatic help pane that tells you how to use Word help, but you still can't open the Navigation Pane (full help that contains looking through the index), one needs to lower his security for ActiveX files in your browser. The one that works is: (Under Changing ActiveX controls and plug-ins) Change Automatic Prompting for ActiveX controls from disable to enable. -- 5tulips ----------- ...

Do I need to reinstall Outlook?
I have a problem with Outlook. I have a MSN account so I also have Outlook Connector. A week ago I had a problem with my email. All my past email was no longer there just empty folders. I went to Microsoft Discussion Group and ask how to recover my old emails, but never got a reply. If I went to Windows Live and look at the emails they were all still there. After a few days I decided to try something, I removed my MSN account then reinstalled it. All my old emails are now there, but I have messed up my calendar and rules. I set up a rule, but they will not run unless I do...

Code and Creation 60240
This is a free and informational site I created for application development and application development source on the net. Enjoy, and it's free, nothing to register oir sign up for just an informational site. http://codeandcreation.com l%Y)S+lP$*WKUy*dXX/efx/c( ... I want a AnimationExtender to run only once but this code produces a complier error This works OK: <ajaxToolkit:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="TableTopQQ"> But if the user returns to this page I don't want the animation to run a second time. So in the Load event I placed: CType(FindControlRecursive(Me, "AnimationExtender1"), System.Web.UI.Control).Enabled = False This got me a "not a member" error so I changed to Visible and ran debug with a break point. Looking at: FindControlRecursive(Me, "AnimationExtender1") I see that it does fi... Calendar Help Hi, Reminders are not popping up for meetings on my calendar. They are showing in OWA, and on my bberry but not in outlook. Any help would be greatly appreciated. Thank you in advance. Do you have Outlook set to display the reminder? Tools > Options > Other > Advanced Options > Reminder Options Check the box that that indicates you want to display the reminder. -- Kathleen Orland Outlook Tips: http://www.outlook-tips.net/ http://www.howto-outlook.com/ "Steve Katz" wrote: > Hi, > > Reminders are not popping up for meetings on my calendar. They... Help with Excel Extraction Hi Can anyone please help? How do I do the following: I would like to extract information based on the following criteria. We open excel up and the first screen opens with 6 headings showing: Setting goals and objectives Marketing Manpower planning Financial matters Performance review Business planning I then choose to click on say the �Marketing box� which I want it to automatically open a new screen with say 7 predetermined boxes [i.e. previously defined for inclusion within the marketing box] showing: PR Sales Market research Competitor review Direct marketing Networking Advertisin... Error Code 0x80070001 I had a virus on my computer (Windows XP). I performed a Full System Recovery. I reloaded MS Office 2003. I had NOrton AV already installed. I have been trying to reinstall NAV, but it tells me that I need to download WinXP SP2. I have WinXP SP1 (yes my computer is old) I tried downloading SP2, but I keep getting error codes, i.e., the one listed above and 0x87ff0004. It also tells me that it can't copy the file - printuit or something like that. Please help if you can Back-up any personal data (none of which should be considered 100% trustworthy at this point... need help outgoing mail getting delayed... and some are getting sent back completely because it is taking too lon to send them. we have an exchange server and our guy can't figure i out. people are having trouble sending to certain emails. we ge delay errors from our exchange server and even some system admi messages saying the attempt to send has been rejected completel because it is taking too long, and these are small files too. from exchange server: "This is an automatically generated Delivery Status Notification. THIS IS A WARNING MESSAGE ONLY. YOU DO NOT NEED TO RESEND YOUR MESSAGE. Delivery to the following recip... Knowledge Base email or cut-and-paste needed We have CRM 3.0 and we are trying to start using the Service\Knowledge Base functionality. One major problem we have run into is that we have no decent way of sending information; you can't email an article, and the cut and paste functionality is not enabled. I found article 920123 which claimed to have a workaround, in the form of some code to add into the ISV.Config file. I followed the directions religiously and tried it several times, but each time it would take down CRM with a site map error. Here is the 920123 article: http://kbalertz.com/920123/cannot-select-knowledge-art... Help with this Event Procedure Hi there I currently have this code in my database but I can't seem to make it work (i.e. no new names are added to my combo box). I don't think I have attached the event procedure properyly either. Where should I put it? Private Sub Coach_NotInList(NewData As String, Response As Integer) intAnswer = MsgBox("This coach" & NewData & " is not currently in the list." & vbCrLf & _ "Would you like to add this coach to the list now?" _ , vbQuestion + vbYesNo, "This coach") If intAnswer = vbYes Then str... Help with inserting lines I have cells in column A where it is written "Account" in some cells. what i want is that upon finding "Account" in cell A it inserts a lin below it and then find another text " Account" please help and another macro which upon finding "Customer" in column deletes tha entire ro -- Message posted from http://www.ExcelForum.com Hi try the following macro for inserting rows Sub insert_rows() Dim lastrow As Long Dim row_index As Long lastrow = ActiveSheet.Cells(Rows.count, "A").End(xlUp).row For row_index = lastrow - 1 To 1 Step -1 If l... Need help with PASTE_SPECIAL-VALUES Is there a formula that allows you to copy an array of cells an paste-values these cells into a different array automatically? If no please read below... When importing large tables of numbers from the internet, I tried to d everything I knew to do to get Excel to recognize them as number (formatted the cells as numbers, multiplied the cells by 1, and =i cell>0,cell,"0" but none of these change its format. After importing data from the internet, it does not allow me to sor the cells unless I copy/paste-values it first. Maybe there is anothe way to also get around this; do yo... Edit box Hi All, I want to create a simple program which has to write in an editbox numbers from 1 to 10, each on a different line. I created an integer member variable and I use a for loop to generate the numbers, but I don't know how to display them on different lines in the editbox. Any help appreciated Regards, Nicolae Just insert "\r\n". -- Jonathan Wood SoftCircuits http://www.softcircuits.com Available for consulting: http://www.softcircuits.com/jwood/resume.htm "Nicolae Fieraru" <nospam@please.com> wrote in message news:41ec500a$1@duster.adelaide.on.ne...

Lost key code
Hi: Now that I have solved my book format problem I find that my my main printer doesn't want to cooperate in double-sided printing. But when I tried to install Publisher on a second household computer I saw that the orginal case, with the KEY CODE, was long gone. How do I retrieve the original KEY CODE for my 2002 Publisher disc? Thanks again. MargeHD -- MargeHD Download Belarc and run. I'm pretty sure it has the product keys for Office XP. http://www.belarc.com/free_download.html -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microso...

Need WAN0distributed filesystem... Groove Server?
I have a client with a workforce that are geographically distributed, and as such, doesn't have a single office where all users are located. They have a few servers, including an AD domain, and we have been using the Frontpage Server Extensions of IIS5 (Server 2k3) on their data server to share files over the WAN, but Windows 7 and the newest version of Mac OS X don't appear to be working properly with the (admittedly cheesy) FPSE solution. The way they were doing it, they just added a "My Network Place" to their XP installations that pointed to http://server....

Error code 1603
Just recently, I downloaded version 7.1 for my Wireless Mouse Explorer v.2 and tried to install it. It does not ending in an error code 1603. I investigated that error code and found no helpful explanation under Microsoft's support except for the extraordinary helpful hint that this error is by design ...HuuH? What a BS. I followed all instruction by removing Intellipoint, did a Clean up afterwards etc. Still no success. I had to install the old version 6,2 and even this caused some problems. At one time I had a MS techie from India on the phone and he saw what happened and...

Need help to create a query
Hi. I need to build a query, that I don't know if it's easy or difficult. I have a production plan. I in this production plan I have the product that i'm to produce. Image: ProductA ProductB ProductA and ProductB are composed by several other products, such as sugar, milk, chocolat, etc... When, to help my colleage a build a query that tells her to many quantaty of each ingreadient she needs to produce all products, in this case Product A and B. This querie says how much quantaty she nedd of sugar and the name of the lot where the sugar is. This query insert the query...