Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy and Paste in Macro

I have created a macro to Find (Edit, Find) 34000 and when it finds 34000
excel is to copy 34000 and paste this two columns from where it is and bold
the original cell. My problem is when 34000 moves my macro won't work
because the macro is tied to the cell 34000 was in when I created the macro.
How can I rewrite the code to not get tied to 34000. Here is a sample of the
code:

Range("A1").Select
Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("A12").Select
Selection.Font.Bold = True

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Copy and Paste in Macro

hello, try this

Sub test()
Range("A1").Select
Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Copy ActiveCell.Offset(0, 2)
ActiveCell.Font.Bold = True
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Copy and Paste in Macro

Sub test()
Dim c As Range
Set c = Cells.Find("34000", After:=Cells(65536, 1), _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
c.Offset(0, 2) = CStr(c.Value)
c.Offset(0, 2).Font.Bold = True
End If
End Sub

"AccessNewbie" wrote:

I have created a macro to Find (Edit, Find) 34000 and when it finds 34000
excel is to copy 34000 and paste this two columns from where it is and bold
the original cell. My problem is when 34000 moves my macro won't work
because the macro is tied to the cell 34000 was in when I created the macro.
How can I rewrite the code to not get tied to 34000. Here is a sample of the
code:

Range("A1").Select
Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Range("A12").Select
Selection.Font.Bold = True

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy and Paste in Macro

this is perfect. Thank You.

Can you tell me if I was searching for 34000 and wanted to delete the entire
row with that how would I change this?

"GTVT06" wrote:

hello, try this

Sub test()
Range("A1").Select
Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Copy ActiveCell.Offset(0, 2)
ActiveCell.Font.Bold = True
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Copy and Paste in Macro

On Aug 11, 12:20*pm, AccessNewbie
wrote:
this is perfect. *Thank You. *

Can you tell me if I was searching for 34000 and wanted to delete the entire
row with that how would I change this?



"GTVT06" wrote:
hello, try this


Sub test()
Range("A1").Select
* * Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
* * * * :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
* * * * False, SearchFormat:=False).Activate
* * ActiveCell.Copy ActiveCell.Offset(0, 2)
* * ActiveCell.Font.Bold = True
End Sub- Hide quoted text -


- Show quoted text -


Hello this will delete the row.

Range("A1").Select
Cells.Find(What:="34000", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.EntireRow.Delete
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
Macro to copy and paste values (columns)I have a macro file built C02C04 Excel Programming 2 May 2nd 08 01:51 PM
copy multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM


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"