PC Review


Reply
Thread Tools Rate Thread

Altering Paste Data

 
 
Suzanne
Guest
Posts: n/a
 
      13th May 2010
I'm pulling data from one worksheet to another with:

Sub IMPORT()

Dim myrange, copyrange As Range
Sheets("IMPORT FROM").Select
Set myrange = Range("C2:C200")
For Each c In myrange
If c.Value <> "" Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If

End If
Next
copyrange.Copy
Sheets("IMPORT TO").Select
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteValues

End Sub

1. Columns C & D in 'IMPORT FROM' contain first name and last name.

Q: Can I combine this data when pasting names (which range anywhere from
1-200 names), i.e., combine first and last name in 'IMPORT TO'!A4:A200.

2. Columns E through AD in 'IMPORT FROM' contain three variables:
0-9%
10-50%
51-100%

Note: These variables will not necessarily appear in every row/column;
however, they will always be associated with a name.

Q: How can I convert the variable to a letter when pasting to 'IMPORT TO';
specifically:
0-9% = R (Rarely)
10-50% = S (Sometimes)
51-100% = F (Frequently)

BTW... reducing the size of the variable to a single digit is needed to fit
all the data onto a hardcopy report that is already tight on legal size paper.

Thank you
 
Reply With Quote
 
 
 
 
Roger Govier
Guest
Posts: n/a
 
      13th May 2010
Hi Suzanne

Try the following
Sub MoveData()
Dim wsF As Worksheet, wsT As Worksheet
Dim i As Long

Set wsF = ThisWorkbook.Sheets("Import From")
Set wsT = ThisWorkbook.Sheets("Import To")

For i = 2 To 200
If wsF.Cells(i, "C") <> "" Then
wsT.Cells(i, "A") = wsF.Cells(i, "C") & " " & wsF.Cells(i, "D")
wsF.Range(wsF.Cells(i, "E"), wsF.Cells(i, "AD")).Copy
wsT.Cells(i, "B")
End If
Next

With wsT.Range("A2:AD200")
.Replace What:="0-9%", Replacement:="R", SearchOrder:=xlByRows
.Replace What:="10-50%", Replacement:="S", SearchOrder:=xlByRows
.Replace What:="51-100%", Replacement:="F", SearchOrder:=xlByRows
End With

wsT.Columns("A:A").EntireColumn.AutoFit
wsT.Columns("B:AB").ColumnWidth = 1.5
End Sub

--
Regards
Roger Govier

Suzanne wrote:
> I'm pulling data from one worksheet to another with:
>
> Sub IMPORT()
>
> Dim myrange, copyrange As Range
> Sheets("IMPORT FROM").Select
> Set myrange = Range("C2:C200")
> For Each c In myrange
> If c.Value <> "" Then
> If copyrange Is Nothing Then
> Set copyrange = c.EntireRow
> Else
> Set copyrange = Union(copyrange, c.EntireRow)
> End If
>
> End If
> Next
> copyrange.Copy
> Sheets("IMPORT TO").Select
> Range("A4").Select
> Selection.PasteSpecial Paste:=xlPasteValues
>
> End Sub
>
> 1. Columns C & D in 'IMPORT FROM' contain first name and last name.
>
> Q: Can I combine this data when pasting names (which range anywhere from
> 1-200 names), i.e., combine first and last name in 'IMPORT TO'!A4:A200.
>
> 2. Columns E through AD in 'IMPORT FROM' contain three variables:
> 0-9%
> 10-50%
> 51-100%
>
> Note: These variables will not necessarily appear in every row/column;
> however, they will always be associated with a name.
>
> Q: How can I convert the variable to a letter when pasting to 'IMPORT TO';
> specifically:
> 0-9% = R (Rarely)
> 10-50% = S (Sometimes)
> 51-100% = F (Frequently)
>
> BTW... reducing the size of the variable to a single digit is needed to fit
> all the data onto a hardcopy report that is already tight on legal size paper.
>
> Thank you

 
Reply With Quote
 
Suzanne
Guest
Posts: n/a
 
      13th May 2010
Thanks VERY much!!

"Roger Govier" wrote:

> Hi Suzanne
>
> Try the following
> Sub MoveData()
> Dim wsF As Worksheet, wsT As Worksheet
> Dim i As Long
>
> Set wsF = ThisWorkbook.Sheets("Import From")
> Set wsT = ThisWorkbook.Sheets("Import To")
>
> For i = 2 To 200
> If wsF.Cells(i, "C") <> "" Then
> wsT.Cells(i, "A") = wsF.Cells(i, "C") & " " & wsF.Cells(i, "D")
> wsF.Range(wsF.Cells(i, "E"), wsF.Cells(i, "AD")).Copy
> wsT.Cells(i, "B")
> End If
> Next
>
> With wsT.Range("A2:AD200")
> .Replace What:="0-9%", Replacement:="R", SearchOrder:=xlByRows
> .Replace What:="10-50%", Replacement:="S", SearchOrder:=xlByRows
> .Replace What:="51-100%", Replacement:="F", SearchOrder:=xlByRows
> End With
>
> wsT.Columns("A:A").EntireColumn.AutoFit
> wsT.Columns("B:AB").ColumnWidth = 1.5
> End Sub
>
> --
> Regards
> Roger Govier
>
> Suzanne wrote:
> > I'm pulling data from one worksheet to another with:
> >
> > Sub IMPORT()
> >
> > Dim myrange, copyrange As Range
> > Sheets("IMPORT FROM").Select
> > Set myrange = Range("C2:C200")
> > For Each c In myrange
> > If c.Value <> "" Then
> > If copyrange Is Nothing Then
> > Set copyrange = c.EntireRow
> > Else
> > Set copyrange = Union(copyrange, c.EntireRow)
> > End If
> >
> > End If
> > Next
> > copyrange.Copy
> > Sheets("IMPORT TO").Select
> > Range("A4").Select
> > Selection.PasteSpecial Paste:=xlPasteValues
> >
> > End Sub
> >
> > 1. Columns C & D in 'IMPORT FROM' contain first name and last name.
> >
> > Q: Can I combine this data when pasting names (which range anywhere from
> > 1-200 names), i.e., combine first and last name in 'IMPORT TO'!A4:A200.
> >
> > 2. Columns E through AD in 'IMPORT FROM' contain three variables:
> > 0-9%
> > 10-50%
> > 51-100%
> >
> > Note: These variables will not necessarily appear in every row/column;
> > however, they will always be associated with a name.
> >
> > Q: How can I convert the variable to a letter when pasting to 'IMPORT TO';
> > specifically:
> > 0-9% = R (Rarely)
> > 10-50% = S (Sometimes)
> > 51-100% = F (Frequently)
> >
> > BTW... reducing the size of the variable to a single digit is needed to fit
> > all the data onto a hardcopy report that is already tight on legal size paper.
> >
> > Thank you

> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Altering data within columns Mark909 Microsoft Access 2 13th Nov 2008 04:01 PM
help with vba altering access data Hootyman Microsoft Access VBA Modules 1 12th Oct 2008 08:10 PM
Altering data and new values =?Utf-8?B?S2l0dGVu?= Microsoft Access 1 20th Apr 2007 06:41 AM
access altering data? =?Utf-8?B?ZGJlbm5ldHQ=?= Microsoft Access Forms 3 10th Aug 2006 06:21 PM
Cut and paste without altering cell reference ski-rdu Microsoft Excel Worksheet Functions 2 16th Jun 2004 12:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:04 AM.