Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
ian123
 
Posts: n/a
Default help to paste via visual basic

thanks for replying maybe i do need a VB sample.
Maybe I originally explained it To simply :(
Basically instead of hello i really want to print an address on a different
sheet(one address line per cell vertically) but i have about 100 different
addresses.
Example:

IF cell a2 on sheet 1 says "1" then copy the address (cells a1 to a5 on sheet
1) to cells d1 to d5 on sheet 2

if cell A2 on sheet 1 says "54" then copy THAT address (cells a1 to a5 on
sheet 1) to cells d10 to d15 on sheet 2
ANYONES HELP WOULD BE VERY APPRECIATED thanks

"RJ" wrote:

You can put a formula in cell A2:

=if(A1=1,"Hello","")

And cell F6 would have the formula:

=if(A1=5,"Hello","")

If you did not want to put formulas into all of the cells you want the
message to appear then you would have to use some VBA. I could provide some
sample codes, but for a new user this might be a little overwhelming.

"ian123" wrote:

i have a cell which will have a number put in it.how do i tell exel to paste
to different cells (depending on what number is put in the cell)

EXAMPLE :
if the cell contains "1" then paste "hello" in cell A2

if cell contains "5" then paste "hello" in cell F6


  #2   Report Post  
Posted to microsoft.public.excel.newusers
Gary''s Student
 
Posts: n/a
Default help to paste via visual basic

Try:

Sub ian()

Dim r1 As Range
Dim r2 As Range
Dim r3 As Range
Dim r4 As Range

Set r1 = Sheets("Sheet1").Range("A1")
Set r2 = Sheets("Sheet1").Range("A1:A5")
Set r3 = Sheets("Sheet2").Range("D1")
Set r4 = Sheets("Sheet2").Range("D10")

If r1.Value = 1 Then
r2.Copy r3
Else
If r1.Value = 54 Then
r2.Copy r4
End If
End If

End Sub

This has been coded for maximum clarity rather than least lines of code.
--
Gary''s Student


"ian123" wrote:

thanks for replying maybe i do need a VB sample.
Maybe I originally explained it To simply :(
Basically instead of hello i really want to print an address on a different
sheet(one address line per cell vertically) but i have about 100 different
addresses.
Example:

IF cell a2 on sheet 1 says "1" then copy the address (cells a1 to a5 on sheet
1) to cells d1 to d5 on sheet 2

if cell A2 on sheet 1 says "54" then copy THAT address (cells a1 to a5 on
sheet 1) to cells d10 to d15 on sheet 2
ANYONES HELP WOULD BE VERY APPRECIATED thanks

"RJ" wrote:

You can put a formula in cell A2:

=if(A1=1,"Hello","")

And cell F6 would have the formula:

=if(A1=5,"Hello","")

If you did not want to put formulas into all of the cells you want the
message to appear then you would have to use some VBA. I could provide some
sample codes, but for a new user this might be a little overwhelming.

"ian123" wrote:

i have a cell which will have a number put in it.how do i tell exel to paste
to different cells (depending on what number is put in the cell)

EXAMPLE :
if the cell contains "1" then paste "hello" in cell A2

if cell contains "5" then paste "hello" in cell F6


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
Visual basic Check Box and the IF formula dingo33 Excel Discussion (Misc queries) 3 February 15th 06 04:57 PM
Trust access to visual basic project in XP systems kasi Excel Discussion (Misc queries) 5 October 13th 05 01:32 PM
Linking to Visual Basic for Applications Help Files Glynn Excel Discussion (Misc queries) 0 October 8th 05 01:29 AM
Printing in Visual Basic bjh96 Excel Discussion (Misc queries) 1 June 17th 05 08:22 PM
Excel Shortcut Opens Visual Basic sinistersims Excel Discussion (Misc queries) 1 June 1st 05 11:18 PM


All times are GMT +1. The time now is 06:28 PM.

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

About Us

"It's about Microsoft Excel"