Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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
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
clean up code a little terilad Excel Discussion (Misc queries) 12 April 12th 10 07:35 PM
Clean up code Dorian C. Chalom Excel Programming 3 November 7th 09 02:28 AM
help me clean up this code Dave F[_2_] Excel Programming 2 June 14th 07 07:50 PM
Clean up code. Tim Excel Programming 2 October 1st 04 05:37 PM
Help clean up this code... scottnshelly[_32_] Excel Programming 8 June 21st 04 09:30 PM


All times are GMT +1. The time now is 11:16 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"