Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Difficult macros


I have a list of data on sheet1. In column A I have a list of countries,
in column C-L there is a list of figures relating to column A. On sheet
2 I have lists of data that I need to get into the table on sheet A.
The data I need (from sheet2) is when column B=column A(sheet1) I need
the data from column K to replace the figure in column C of sheet one
shifting the figures in the row to the right. If column D
(sheet2)=column A (sheet1) I need to insert the value from column L in
a similar fashion. Each name in column A appears a number of times on
sheet two and I need a program that can read them in order regardless
of whether they appear in column B or D.

Any help at all is most appreciated


Phil


--
phil2006
------------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...o&userid=35092
View this thread: http://www.excelforum.com/showthread...hreadid=551797

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Difficult macros

Phil,

It is hard to determine what you really want, but I think I've figured it
out. I assumed that the data starts on the first row and will continue the
rest of the sheet. Obviously there is alot that can be done with this (ie.
deleting data after column L, checking for blanks, etc), but this Sub gets
the main issue out of the way.

Sub MoveData()
Dim cntry As String
For i = 1 To Sheet1.UsedRange.Rows.Count
If Cells(i, "A") < "" Then
cntry = Cells(i, "A")
For j = 1 To Sheet2.UsedRange.Rows.Count
If Sheet2.Cells(j, "B") = cntry Then
Sheet2.Cells(j, "K").Copy
Sheet1.Cells(i, "B").Insert (xlShiftToRight)
Sheet1.Cells(i, "B").PasteSpecial (xlPasteValues)
End If
If Sheet2.Cells(j, "D") = cntry Then
Sheet2.Cells(j, "L").Copy
Sheet1.Cells(i, "B").Insert (xlShiftToRight)
Sheet1.Cells(i, "B").PasteSpecial (xlPasteValues)
End If
Next
End If
Next
End Sub

Mike



"phil2006" wrote:


I have a list of data on sheet1. In column A I have a list of countries,
in column C-L there is a list of figures relating to column A. On sheet
2 I have lists of data that I need to get into the table on sheet A.
The data I need (from sheet2) is when column B=column A(sheet1) I need
the data from column K to replace the figure in column C of sheet one
shifting the figures in the row to the right. If column D
(sheet2)=column A (sheet1) I need to insert the value from column L in
a similar fashion. Each name in column A appears a number of times on
sheet two and I need a program that can read them in order regardless
of whether they appear in column B or D.

Any help at all is most appreciated


Phil


--
phil2006
------------------------------------------------------------------------
phil2006's Profile: http://www.excelforum.com/member.php...o&userid=35092
View this thread: http://www.excelforum.com/showthread...hreadid=551797


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
Help, too difficult for me. Menno Excel Worksheet Functions 4 January 19th 06 01:53 PM
Too difficult for me, please help. Menno Excel Worksheet Functions 3 October 7th 05 02:01 PM
Difficult but do-able? Jaydubs Excel Discussion (Misc queries) 8 October 6th 05 11:01 AM
Is this difficult??? mingolo Excel Programming 1 September 15th 05 07:03 PM
Ok I have to be difficult Dominique Feteau[_2_] Excel Programming 7 August 26th 05 05:24 PM


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