Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Help, Copy Cell, using VB

Hello,

I have a long list of values in one sheet of an Excel Workbook. The list
only spans Column A & B. I have 2 cells (F2, G2) in which I enter new values
to be put into the list. After entering the new values in the 2 cells I
created a button that has code to look for an open row, paste the new entry,
then clear the contents of the entry cells(F2, G2).

Everything is working perfectly except that I have border formatting on my
entry cells and that formatting also copies to the list cells. Using the VB
code, is there a way to only copy the text out of the cell and past rather
than copying the properties of the cell as well?

I've pasted my button code as a reference.

Private Sub Insert_Click()

Dim x, y

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Value.Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop
End Sub


Thanks in advance for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Updated Code

Sorry I had some errors in the code I posted in the original message.

Private Sub Insert_Click()

Dim x, y

x = 1

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop


End Sub

"Adam" wrote:

Hello,

I have a long list of values in one sheet of an Excel Workbook. The list
only spans Column A & B. I have 2 cells (F2, G2) in which I enter new values
to be put into the list. After entering the new values in the 2 cells I
created a button that has code to look for an open row, paste the new entry,
then clear the contents of the entry cells(F2, G2).

Everything is working perfectly except that I have border formatting on my
entry cells and that formatting also copies to the list cells. Using the VB
code, is there a way to only copy the text out of the cell and past rather
than copying the properties of the cell as well?

I've pasted my button code as a reference.

Private Sub Insert_Click()

Dim x, y

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Value.Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop
End Sub


Thanks in advance for any help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Updated Code

hi,
the copy command copies all. but you can selectively paste what was copied.
this is the line that is giving you the problem
Range(Cells(2, 6), Cells(2, 7)).Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
this would paste all.
I might suggest this...
Range(Cells(2, 6), Cells(2, 7)).Copy
Range(Cells(x, 1), Cells(x, 2)).pastespecial xlAllExceptBorders
note: you can replace xlAllExceptBorders with 6
There are other pastespecials.
In vb help type Pastespecial to learn more.

regards
FSt1

"Adam" wrote:

Sorry I had some errors in the code I posted in the original message.

Private Sub Insert_Click()

Dim x, y

x = 1

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop


End Sub

"Adam" wrote:

Hello,

I have a long list of values in one sheet of an Excel Workbook. The list
only spans Column A & B. I have 2 cells (F2, G2) in which I enter new values
to be put into the list. After entering the new values in the 2 cells I
created a button that has code to look for an open row, paste the new entry,
then clear the contents of the entry cells(F2, G2).

Everything is working perfectly except that I have border formatting on my
entry cells and that formatting also copies to the list cells. Using the VB
code, is there a way to only copy the text out of the cell and past rather
than copying the properties of the cell as well?

I've pasted my button code as a reference.

Private Sub Insert_Click()

Dim x, y

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Value.Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop
End Sub


Thanks in advance for any help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Updated Code

You can also transfer values:

Range(Cells(x, 1), Cells(x, 2)).Value=Range(Cells(2, 6), Cells(2, 7)).Value

(new range values = old range value)

--
steveB

Remove "AYN" from email to respond
"Adam" wrote in message
...
Sorry I had some errors in the code I posted in the original message.

Private Sub Insert_Click()

Dim x, y

x = 1

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop


End Sub

"Adam" wrote:

Hello,

I have a long list of values in one sheet of an Excel Workbook. The list
only spans Column A & B. I have 2 cells (F2, G2) in which I enter new
values
to be put into the list. After entering the new values in the 2 cells I
created a button that has code to look for an open row, paste the new
entry,
then clear the contents of the entry cells(F2, G2).

Everything is working perfectly except that I have border formatting on
my
entry cells and that formatting also copies to the list cells. Using the
VB
code, is there a way to only copy the text out of the cell and past
rather
than copying the properties of the cell as well?

I've pasted my button code as a reference.

Private Sub Insert_Click()

Dim x, y

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Value.Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop
End Sub


Thanks in advance for any help.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Updated Code

Thank you both. Either method works just fine. I appriciate the help!

"Adam" wrote:

Sorry I had some errors in the code I posted in the original message.

Private Sub Insert_Click()

Dim x, y

x = 1

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop


End Sub

"Adam" wrote:

Hello,

I have a long list of values in one sheet of an Excel Workbook. The list
only spans Column A & B. I have 2 cells (F2, G2) in which I enter new values
to be put into the list. After entering the new values in the 2 cells I
created a button that has code to look for an open row, paste the new entry,
then clear the contents of the entry cells(F2, G2).

Everything is working perfectly except that I have border formatting on my
entry cells and that formatting also copies to the list cells. Using the VB
code, is there a way to only copy the text out of the cell and past rather
than copying the properties of the cell as well?

I've pasted my button code as a reference.

Private Sub Insert_Click()

Dim x, y

Do Until y = 1

If Cells(x, 1) = "" Then

Range(Cells(2, 6), Cells(2, 7)).Value.Copy _
Destination:=Range(Cells(x, 1), Cells(x, 2))
Range(Cells(2, 6), Cells(2, 7)).ClearContents
Worksheets("Sheet1").Range("A1").Sort _
Key1:=Worksheets("Sheet1").Columns("b"), _
Key1:=Worksheets("Sheet1").Columns("a"), _
Header:=xlGuess

y = 1

End If

x = x + 1

Loop ' End Do Until Loop
End Sub


Thanks in advance for any help.

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
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
How can I copy a value from a cell and paste it into another cell while adding it to the previous value in that cell [email protected] Excel Worksheet Functions 2 November 7th 07 09:39 AM
I copy a formula and the results copy from the original cell brooklynsd Excel Discussion (Misc queries) 1 June 23rd 07 01:35 AM
VBA to copy to empty cell directly below a cell when analogous cells in different column have same value as each other? SROSENYC Excel Programming 1 August 5th 03 04:34 AM


All times are GMT +1. The time now is 07:15 AM.

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"