Click here to Skip to main content
15,889,372 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How i can use stored procedure in vb.net with two parameters Pin
tastini5-May-14 9:18
professionaltastini5-May-14 9:18 
AnswerRe: How i can use stored procedure in vb.net with two parameters Pin
ZurdoDev5-May-14 9:26
professionalZurdoDev5-May-14 9:26 
GeneralRe: How i can use stored procedure in vb.net with two parameters Pin
tastini5-May-14 9:34
professionaltastini5-May-14 9:34 
QuestionRe: How i can use stored procedure in vb.net with two parameters Pin
ZurdoDev5-May-14 9:35
professionalZurdoDev5-May-14 9:35 
GeneralRe: How i can use stored procedure in vb.net with two parameters Pin
tastini5-May-14 9:36
professionaltastini5-May-14 9:36 
AnswerRe: How i can use stored procedure in vb.net with two parameters Pin
ZurdoDev5-May-14 9:38
professionalZurdoDev5-May-14 9:38 
GeneralRe: How i can use stored procedure in vb.net with two parameters Pin
Dave Kreskowiak5-May-14 9:28
mveDave Kreskowiak5-May-14 9:28 
Questioncopying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 5:51
David Rubin5-May-14 5:51 
I need to copy multiple cells from one worksheet (Sheet 1) and paste them into another worksheet (Sheet 4). I want each cell from sheet 1 to paste in a specific column in sheet 4, to the next available cell in sheet 4. I can only get one column to correctly paste. When I change the code, it updates another column, but not the previous one.

Here is what I need:

Copy from Paste to
SHEET 1, cell D10 SHEET 4 Column B, the next available cell
SHEET 1, cell D12 SHEET 4 Column D, the next available cell
SHEET 1, cell D14 SHEET 4 Column E, the next available cell
SHEET 1, cell E22 SHEET 4 Column C, the next available cell

Here is the current code I am using:

Sub Mail_workbook_Outlook_2()
' Works in Excel 2000, Excel 2002, Excel 2003, Excel 2007, Excel 2010, Outlook 2000, Outlook 2002, Outlook 2003, Outlook 2007, Outlook 2010.
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim OutApp As Object
Dim OutMail As Object

Set wb1 = ActiveWorkbook
If Val(Application.Version) >= 12 Then
If wb1.FileFormat = 51 And wb1.HasVBProject = True Then
MsgBox "There is VBA code in this xlsx file. There will" & vbNewLine & _
"be no VBA code in the file you send. Save the" & vbNewLine & _
"file as a macro-enabled (. Xlsm) and then retry the macro.", vbInformation
Exit Sub
End If
End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

' Make a copy of the file.
' If you want to change the file name then change only TempFileName variable.
'TempFilePath = Environ$("temp") & "\"
'TempFileName = "Copy of " & wb1.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")
'FileExtStr = "." & LCase(Right(wb1.Name, _
Len(wb1.Name) - InStrRev(wb1.Name, ".", , 1)))

wb1.SaveCopyAs TempFilePath & TempFileName & FileExtStr
'Set wb2 = Workbooks.Open(TempFilePath & TempFileName & FileExtStr)

Set OutApp = CreateObject("Outlook.Application")

Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
' Change the mail address and subject in the macro before you run this procedure.
With OutMail
.To = "ENTER EMAIL ADDRESS HERE"
.CC = ""
.BCC = ""
.Subject = "Work Order Request " & Format(Now, "dd-mmm-yy h:mm:ss")
.Body = "Please see attached maintenance work order"
.Attachments.Add wb1.FullName
' You can add other files by uncommenting the following line.
'.Attachments.Add ("C:\test.txt")
' In place of the following statement, you can use ".Display" to
' display the mail.
.Send
End With
On Error GoTo 0

'wb2.Close SaveChanges:=False

' Delete the file.
'Kill TempFilePath & TempFileName & FileExtStr

Set OutMail = Nothing
Set OutApp = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True

Range("D14").Select
Selection.Copy
Sheets("Sheet4").Select
lMaxRows = Cells(Rows.Count, "E").End(xlUp).Row
Range("E" & lMaxRows + 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
lMaxRows = Cells(Rows.Count, "E").End(xlUp).Row
Range("E" & lMaxRows + 1).Select
On Error Resume Next

MsgBox "Your work order request has been sent to maintenance."
End With
End Sub
SuggestionRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:14
professionalZurdoDev5-May-14 9:14 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:22
David Rubin5-May-14 9:22 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:29
professionalZurdoDev5-May-14 9:29 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:40
David Rubin5-May-14 9:40 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:43
professionalZurdoDev5-May-14 9:43 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:48
David Rubin5-May-14 9:48 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:49
professionalZurdoDev5-May-14 9:49 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 12:27
David Rubin5-May-14 12:27 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 12:58
professionalZurdoDev5-May-14 12:58 
QuestionMicrosoft.Visualbasic Pin
SPSandy5-May-14 4:57
SPSandy5-May-14 4:57 
AnswerRe: Microsoft.Visualbasic Pin
Dave Kreskowiak5-May-14 6:20
mveDave Kreskowiak5-May-14 6:20 
GeneralRe: Microsoft.Visualbasic Pin
SPSandy5-May-14 9:55
SPSandy5-May-14 9:55 
QuestionE-mail Notification Pin
waner michaud4-May-14 13:23
waner michaud4-May-14 13:23 
AnswerRe: E-mail Notification Pin
Dave Kreskowiak4-May-14 18:37
mveDave Kreskowiak4-May-14 18:37 
QuestionCapture a monochrome image of panel control Pin
gwittlock3-May-14 2:27
gwittlock3-May-14 2:27 
AnswerRe: Capture a monochrome image of panel control Pin
Richard MacCutchan3-May-14 3:32
mveRichard MacCutchan3-May-14 3:32 
GeneralRe: Capture a monochrome image of panel control Pin
gwittlock3-May-14 3:41
gwittlock3-May-14 3:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.