Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to copy text to a specific cell reference

Lets say we have the following on one worksheet (lets call it data):

Supplier No Discount Comment1
12345 5%
67890 10%

On the second worksheet (called info) I will have a vlookup so the use
enters the suplier number and the discount and comments field ar
displayed.

I will have another comments box on the info sheet where users ca
enter comments if the comments field (on the data worksheet) is blank
hence being blank from the lookup.


The user would then click a button to enter the data. This data tha
the user entered would then be copied and pasted to the respectiv
comment field on the data tab.

The reason for doing it like this is that there are over 700 supplier
on any given weekly report and it currently takes a long time to sor
through the supplier data fields.

I came up with this macro: this will always paste the data into cel
d2. However I will need this data to be entered into the comments fiel
for that respective supplier. I thought I could have a formula tha
displays the cell location of where the data should be pasted and us
that in the macro??

Range("B8").Select (This is the user input field)
Selection.Copy
Sheets("Data").Select
Range("d2")Select (Can I put a cell location here that has th
location of where to paste the data)
ActiveSheet.Paste

Many many thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to copy text to a specific cell reference

Assume the supplier no is entered in B7, and column A of the sheet named
"data" is the column with the supplier numbers
set rng = Worksheets("Data").Range("A:A).Find( _
Range("B7")
if not rng is nothing then
Range("B8").copy Destination:=rng.offset(0,3)
Else
msgbox Range("B7") & " supplier no was not found"
End if

--
Regards,
Tom Ogilvy



"shanman_lmtd " wrote in
message ...
Lets say we have the following on one worksheet (lets call it data):

Supplier No Discount Comment1
12345 5%
67890 10%

On the second worksheet (called info) I will have a vlookup so the user
enters the suplier number and the discount and comments field are
displayed.

I will have another comments box on the info sheet where users can
enter comments if the comments field (on the data worksheet) is blank,
hence being blank from the lookup.


The user would then click a button to enter the data. This data that
the user entered would then be copied and pasted to the respective
comment field on the data tab.

The reason for doing it like this is that there are over 700 suppliers
on any given weekly report and it currently takes a long time to sort
through the supplier data fields.

I came up with this macro: this will always paste the data into cell
d2. However I will need this data to be entered into the comments field
for that respective supplier. I thought I could have a formula that
displays the cell location of where the data should be pasted and use
that in the macro??

Range("B8").Select (This is the user input field)
Selection.Copy
Sheets("Data").Select
Range("d2")Select (Can I put a cell location here that has the
location of where to paste the data)
ActiveSheet.Paste

Many many thanks.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to copy text to a specific cell reference

Is that the whole code needed or do I insert that instead of;
Range("d2")Select

It does not seem to be working though - I get the following erro
message on this line.

set rng = Worksheets("Data").Range("A:A).Find( _
Range ("B7")



Compile error:
Expected: List seperator or )


Once again many thank

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to copy text to a specific cell reference

Seriously, if you can't debug that, should you be using macros?

There is a missing paren on the end.

Sub MacroAABB()
Dim rng as Range
set rng = Worksheets("Data").Range("A:A).Find( _
Range("B7").Value)
if not rng is nothing then
Range("B8").copy Destination:=rng.offset(0,3)
Else
msgbox Range("B7").Value & " supplier no was not found"
End if
End Sub


You should look in help at the Find method and become conversant with the
other available arguments.

--
Regards,
Tom Ogilvy


"shanman_lmtd " wrote in
message ...
Is that the whole code needed or do I insert that instead of;
Range("d2")Select

It does not seem to be working though - I get the following error
message on this line.

set rng = Worksheets("Data").Range("A:A).Find( _
Range ("B7")



Compile error:
Expected: List seperator or )


Once again many thanks


---
Message posted from http://www.ExcelForum.com/



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
Need help - Macro to copy a specific range Dileep Chandran Excel Worksheet Functions 9 December 5th 06 09:10 AM
Need help - Macro to copy a specific range Dileep Chandran Excel Worksheet Functions 0 December 4th 06 10:24 AM
copy text to specific cell Tattyfur Excel Discussion (Misc queries) 1 January 5th 06 05:21 PM
Need Macro to copy specific sheet mac Excel Worksheet Functions 1 January 17th 05 08:46 PM
Macro to copy down specific number of rows JA Excel Programming 4 April 26th 04 01:37 PM


All times are GMT +1. The time now is 09:31 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"