ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   MACRO IS NOT WORKING AS IT SHOULD (https://www.excelbanter.com/excel-worksheet-functions/147246-macro-not-working-should.html)

jeannie v

MACRO IS NOT WORKING AS IT SHOULD
 
Hi:

This Macro is almost working, but there is a slight glitsch......When the
person's data from Worksheet 2 to Worksheet 1 start paste in Range A4, only
the first line of data pastes to A4...the rest of the person's data pastes
down below in lines 42 down.....Any help would be greatly
appreciated..........

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range

Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i

End Sub
--
jeannie v

Billy Liddel

MACRO IS NOT WORKING AS IT SHOULD
 
Jeanie, it seems to work for me, I've slightly modified the code but let me
know if it works.

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range
Application.ScreenUpdating = False
Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Cells(1, 1).Select
End If
End If
Next i
Application.CutCopyMode = False
Range("a1").Select
Application.ScreenUpdating = True
End Sub

Regards
Peter

"jeannie v" wrote:

Hi:

This Macro is almost working, but there is a slight glitsch......When the
person's data from Worksheet 2 to Worksheet 1 start paste in Range A4, only
the first line of data pastes to A4...the rest of the person's data pastes
down below in lines 42 down.....Any help would be greatly
appreciated..........

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range

Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i

End Sub
--
jeannie v


jeannie v

MACRO IS NOT WORKING AS IT SHOULD
 
Hi Peter: Thank you for helping me.....I still can't get it to work....I
must be doing something incredibly wrong....All I'm doing is copying and
pasting the macro you sent and it's just not working for me....If I sent you
my workbook, do you think you could see where I might be going wrong? If so,
how would I send it to you.

jeannie v


"Billy Liddel" wrote:

Jeanie, it seems to work for me, I've slightly modified the code but let me
know if it works.

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range
Application.ScreenUpdating = False
Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Cells(1, 1).Select
End If
End If
Next i
Application.CutCopyMode = False
Range("a1").Select
Application.ScreenUpdating = True
End Sub

Regards
Peter

"jeannie v" wrote:

Hi:

This Macro is almost working, but there is a slight glitsch......When the
person's data from Worksheet 2 to Worksheet 1 start paste in Range A4, only
the first line of data pastes to A4...the rest of the person's data pastes
down below in lines 42 down.....Any help would be greatly
appreciated..........

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range

Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i

End Sub
--
jeannie v


Billy Liddel

MACRO IS NOT WORKING AS IT SHOULD
 
Jeannie

e-mail me at peter_athertonAThotmail.com and send the file as an attatchment.

do the obvious with the AT

Peter

"jeannie v" wrote:

Hi Peter: Thank you for helping me.....I still can't get it to work....I
must be doing something incredibly wrong....All I'm doing is copying and
pasting the macro you sent and it's just not working for me....If I sent you
my workbook, do you think you could see where I might be going wrong? If so,
how would I send it to you.

jeannie v


"Billy Liddel" wrote:

Jeanie, it seems to work for me, I've slightly modified the code but let me
know if it works.

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range
Application.ScreenUpdating = False
Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues
Cells(1, 1).Select
End If
End If
Next i
Application.CutCopyMode = False
Range("a1").Select
Application.ScreenUpdating = True
End Sub

Regards
Peter

"jeannie v" wrote:

Hi:

This Macro is almost working, but there is a slight glitsch......When the
person's data from Worksheet 2 to Worksheet 1 start paste in Range A4, only
the first line of data pastes to A4...the rest of the person's data pastes
down below in lines 42 down.....Any help would be greatly
appreciated..........

Sub LoginLogout()
'
'
Dim n As Integer, i As Integer
Dim rng As Range

Sheets("Agent Login-Logout").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Agent Login-Logout").Activate
If Cells(i, "A").Value = "Miller, Chris" Then
Range("A" & i & ":L" & i).Copy
Sheets("Christopher M").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Christopher M").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Else
Sheets("Christopher M").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Christopher M").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i

End Sub
--
jeannie v



All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com