Glad having been of some help.
For further information I would point out that I'am using Office 2016-32bit.
Anyway the code of your macro looks okay.
Glad having been of some help.
For further information I would point out that I'am using Office 2016-32bit.
Anyway the code of your macro looks okay.
Your macro works correctly for me, shows Outlook only when there is no attachment.
Glad having been of some help.
Presuming that your names are in column A from row 1 and have a single comma and a 2 charcter initial you could use this macro. To keep the initials aligned you will have to format the column with a monospaced font (ex. Courier New).
Option Explicit
Sub Pad_With_Space()
Dim x, lr, rng As Range, pos, maxLen
'detect max lenght of names
lr = Range("A" & Rows.Count).End(xlUp).Row
For x = 1 To lr
Set rng = Range("A" & x)
If Len(rng) > maxLen Then maxLen = Len(rng)
Next x
'pad with spaces
For x = 1 To lr
Set rng = Range("A" & x)
pos = InStr(1, rng, ",")
rng = Left(rng, pos) & Space(maxLen - Len(rng) + 1) & Right(rng, 2)
Next x
End Sub
Display More
Glad I was able to help.
It's tricky to use 'Find' with both month and year due to local formatting of dates so I had to change approach, try with this:
Option Explicit
Private Sub WorkSheet_Change(ByVal Target As Range)
Dim rFnd As Long
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("A:A")) Is Nothing Then
rFnd = Range("A1:A" & Target.Row).Find(What:=Target.Value, LookAt:=xlWhole).Row
Range("B" & Target.Row) = Range("B" & rFnd)
Range("C" & Target.Row) = Range("C" & rFnd)
Range("E" & Target.Row) = Range("E" & rFnd)
End If
If Not Intersect(Target, Range("F:F")) Is Nothing Then
For rFnd = 2 To Target.Row
If Month(Range("F" & rFnd)) = Month(Range("F" & Target.Row)) And _
Year(Range("F" & rFnd)) = Year(Range("F" & Target.Row)) Then
Range("H" & Target.Row) = Range("H" & rFnd)
Exit For
End If
Next rFnd
End If
Application.EnableEvents = True
End Sub
Display More
If I correctly understood your request, could be:
Option Explicit
Private Sub WorkSheet_Change(ByVal Target As Range)
Dim rFnd As Long
If Target.Cells.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not Intersect(Target, Range("A:A")) Is Nothing Then
rFnd = Range("A1:A" & Target.Row).Find(What:=Target.Value, LookAt:=xlWhole).Row
Range("B" & Target.Row) = Range("B" & rFnd)
Range("C" & Target.Row) = Range("C" & rFnd)
Range("E" & Target.Row) = Range("E" & rFnd)
End If
If Not Intersect(Target, Range("F:F")) Is Nothing Then
rFnd = Range("F1:F" & Target.Row).Find(What:=Month(Target.Value), LookAt:=xlPart).Row
Range("H" & Target.Row) = Range("H" & rFnd)
End If
Application.EnableEvents = True
End Sub
Display More
Note that I also added Event checking to avoid redundant triggering.
The relevant part of my macro is all in the 'If/Then/End If' so all you have to do is add it to your macro, where depends on how your's is structured, maybe just before your 'End Sub'.
Since I have no idea how your project is structured, I believe that a solution for your second request would be the same, create and add a new 'If/Then/End If' and in it change the references to columns and rows.
Have a try with this macro to be placed in the sheets module.
Option Explicit
Private Sub WorkSheet_Change(ByVal Target As Range)
Dim rFnd As Long
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
rFnd = Range("A1:A" & Target.Row).Find(What:=Target.Value, LookAt:=xlWhole).Row
Range("B" & Target.Row) = Range("B" & rFnd)
Range("C" & Target.Row) = Range("C" & rFnd)
Range("E" & Target.Row) = Range("E" & rFnd)
End If
End Sub
Display More
Points and trophies are arranged automatically by the Forum, all you can do is use "Likes" for the best posts.
You asked for a macro to do the dirty work, I usually use this one to be found here: Link
Option Explicit
Sub LoseThatWeight()
Dim x As Long
Dim LastRow As Long
Dim LastCol As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
On Error Resume Next
For x = 1 To Sheets.Count
With Sheets(x)
.Visible = True
LastRow = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LastCol = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
.Range(.Cells(1, LastCol + 1), .Cells(Rows.Count, Columns.Count)).Delete
.Range(.Cells(LastRow + 1, 1), .Cells(Rows.Count, Columns.Count)).Delete
End With
Next x
On Error GoTo 0
With Application
.Calculation = xlAutomatic
.ScreenUpdating = True
.EnableEvents = True
End With
MsgBox "Done, now save the file"
End Sub
Display More
Never test on original files.
Glad having been of some help.
Did you save the file after Deleting and before any other activity ?
Sorry, no other idea at the moment.
You need to Delete (not only Clear) all rows and columns after the last valid cell.
For rows: Select first empty row, hold Shift, tap End then Down Arrow, release Shift, apply Delete
For columns: Select first empty column, hold Shift, tap End then Right Arrow, release Shift, apply Delete
That's because with MID you extract a string, so when you compare A1=71 it is a string to a number. Should be atleast string to string (or number to number) so your formula in A3 will work with:
=IF(A2="71","seventyone","ERROR")
or
=IF(VALUE(A2)=71,"seventyone","ERROR")
Hi to all.
Try adding this line of code just before you discriminate range "I:I"; might be enough to solve your criticalissue:
If Target.Cells.Count > 1 Then Exit Sub
Glad I was able to help.