Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Paste Special Macro Assistance needed

Currently I have the following Macro:

Sub getvalues()
lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "am") = upheld Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "am") = upheld And IsDate(.Cells(i, "aj")) Then
..Rows(i).Copy Rows(dlr)
Next i
End With
End Sub

The way it currently pulls information is it looks at column AM for any
cells with "upheld". It then checks for a date in AJ. If both are met then
it copies the row.

This works perfectly for certain aspects of my spreadsheets, but I need two
things that I can't figure out. The first, how can I change that above macro
so that it won't clear or delete any information after its been copied over?
Second, how can I change the macro to paste only the values of the cells that
its copying from?

Thanks in advance for any assistance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Paste Special Macro Assistance needed

This procedure will do both. You do not need to copy and paste if you only
want to copy the values.

Sub getvalues()

Dim lr As Long
Dim slr As Long
Dim dlr As Long
Dim i As Long

lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
Rows("2:" & lr).ClearContents

With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
Next i
End With

End Sub


Hope this helps! If so, let me know by clicking "YES" below.

--
Cheers,
Ryan


"akemeny" wrote:

Currently I have the following Macro:

Sub getvalues()
lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "am") = upheld Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "am") = upheld And IsDate(.Cells(i, "aj")) Then
.Rows(i).Copy Rows(dlr)
Next i
End With
End Sub

The way it currently pulls information is it looks at column AM for any
cells with "upheld". It then checks for a date in AJ. If both are met then
it copies the row.

This works perfectly for certain aspects of my spreadsheets, but I need two
things that I can't figure out. The first, how can I change that above macro
so that it won't clear or delete any information after its been copied over?
Second, how can I change the macro to paste only the values of the cells that
its copying from?

Thanks in advance for any assistance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Paste Special Macro Assistance needed

Ryan,

The code that you gave me below is giving me the Compile Error: Next
without For. I can clearly see where you have the For present so I'm not
sure why it isn't working.

"RyanH" wrote:

This procedure will do both. You do not need to copy and paste if you only
want to copy the values.

Sub getvalues()

Dim lr As Long
Dim slr As Long
Dim dlr As Long
Dim i As Long

lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
Rows("2:" & lr).ClearContents

With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
Next i
End With

End Sub


Hope this helps! If so, let me know by clicking "YES" below.

--
Cheers,
Ryan


"akemeny" wrote:

Currently I have the following Macro:

Sub getvalues()
lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "am") = upheld Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "am") = upheld And IsDate(.Cells(i, "aj")) Then
.Rows(i).Copy Rows(dlr)
Next i
End With
End Sub

The way it currently pulls information is it looks at column AM for any
cells with "upheld". It then checks for a date in AJ. If both are met then
it copies the row.

This works perfectly for certain aspects of my spreadsheets, but I need two
things that I can't figure out. The first, how can I change that above macro
so that it won't clear or delete any information after its been copied over?
Second, how can I change the macro to paste only the values of the cells that
its copying from?

Thanks in advance for any assistance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Paste Special Macro Assistance needed

If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
End if '<- added
Next i

akemeny wrote:

Ryan,

The code that you gave me below is giving me the Compile Error: Next
without For. I can clearly see where you have the For present so I'm not
sure why it isn't working.

"RyanH" wrote:

This procedure will do both. You do not need to copy and paste if you only
want to copy the values.

Sub getvalues()

Dim lr As Long
Dim slr As Long
Dim dlr As Long
Dim i As Long

lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
Rows("2:" & lr).ClearContents

With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
Next i
End With

End Sub


Hope this helps! If so, let me know by clicking "YES" below.

--
Cheers,
Ryan


"akemeny" wrote:

Currently I have the following Macro:

Sub getvalues()
lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "am") = upheld Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "am") = upheld And IsDate(.Cells(i, "aj")) Then
.Rows(i).Copy Rows(dlr)
Next i
End With
End Sub

The way it currently pulls information is it looks at column AM for any
cells with "upheld". It then checks for a date in AJ. If both are met then
it copies the row.

This works perfectly for certain aspects of my spreadsheets, but I need two
things that I can't figure out. The first, how can I change that above macro
so that it won't clear or delete any information after its been copied over?
Second, how can I change the macro to paste only the values of the cells that
its copying from?

Thanks in advance for any assistance.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Paste Special Macro Assistance needed

Sorry about that. I forgot to put the End If.

Sub getvalues()

Dim lr As Long
Dim slr As Long
Dim dlr As Long
Dim i As Long

lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
Rows("2:" & lr).ClearContents

With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
End If
Next i
End With

End Sub

Hope this helps! If so, let me know by clicking "YES" below.
--
Cheers,
Ryan


"akemeny" wrote:

Ryan,

The code that you gave me below is giving me the Compile Error: Next
without For. I can clearly see where you have the For present so I'm not
sure why it isn't working.

"RyanH" wrote:

This procedure will do both. You do not need to copy and paste if you only
want to copy the values.

Sub getvalues()

Dim lr As Long
Dim slr As Long
Dim dlr As Long
Dim i As Long

lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
Rows("2:" & lr).ClearContents

With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
If .Cells(i, "AM") = "upheld" And IsDate(.Cells(i, "AJ")) Then
.Rows(i).Value = Rows(dlr).Value
Next i
End With

End Sub


Hope this helps! If so, let me know by clicking "YES" below.

--
Cheers,
Ryan


"akemeny" wrote:

Currently I have the following Macro:

Sub getvalues()
lr = Application.Max(2, Cells(Rows.Count, 1).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Worksheets("Master")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 6 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "am") = upheld Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "am") = upheld And IsDate(.Cells(i, "aj")) Then
.Rows(i).Copy Rows(dlr)
Next i
End With
End Sub

The way it currently pulls information is it looks at column AM for any
cells with "upheld". It then checks for a date in AJ. If both are met then
it copies the row.

This works perfectly for certain aspects of my spreadsheets, but I need two
things that I can't figure out. The first, how can I change that above macro
so that it won't clear or delete any information after its been copied over?
Second, how can I change the macro to paste only the values of the cells that
its copying from?

Thanks in advance for any assistance.



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
Paste-Special - R/T 1004 help needed Jim May Excel Programming 1 February 25th 06 04:50 PM
Cut and Paste using Macro gives paste special method error Lourens Pentz Excel Programming 3 November 21st 04 10:42 PM
Macro assistance needed HJ Excel Programming 3 November 2nd 04 10:46 PM
Code Assistance (Paste Special) Tom Taetsch Excel Programming 1 October 31st 04 11:49 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"