Flux rss
Search : in
By : Relevance Date Username
Statut : Not resolved

Excel: Macro Help

bobgure, on Wednesday 30 April 2008 à 16:08:56
Hello,


I ned some help setting up a macro for Excel.


I have a lost of IDs/SKUs on Sheet 1, and a partial list on Sheet2. What I would like to do is cross-check the two sheets and delete all the rows on Sheet1 that's already listed on sheet2. The IDs/SKUs are on the same column for both sheets.


Any help would be apperciated.
Configuration: Windows XP
Internet Explorer 6.0
Reply to bobgure  Report this message to moderators Go to last message

1


  • This message seems useful, vote!
  • Report this message to moderators
spiderind, on Wednesday 30 April 2008 à 17:02:14
Hai

The following routine is a modified version of something I posted a while back. In that case, the poster want to delete rows on Sheet1 if an ID was *not* found on Sheet2.
The comment line with the *** shows the line where the change was made to delete rows on Sheet1 if the ID *was* found on Sheet2.

Explanation:

When using Set c =.Find(item):

c will contain all the attributes of the item if it is found. e.g. c.Address will return the cell address of the item, c.Font.Name will return...well, I'm sure you can figure that out.

c will be set to Nothing if it is not found.

Now, in the VBA programmers' infinite wisdom, they decided to use TRUE as the only way to check and see if an item was found.

When "If c Is Nothing" returns TRUE, the item wasn't found.

and

When "If Not c is Nothing" returns TRUE the item was found. (I would have prefered "If c is Not Nothing", but, hey, they didn't check with me first!)

So here's the code using "If Not c" to delete rows if the item is found.

Sub DeleteIDs()
'Assume Sheet1 has long list, Sheet2 has short list
'Find last piece of data in Sheet1 Column A
LastRow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
'Start at bottom of Column A and get ID
For NxtID = LastRow To 1 Step -1
ID = Sheets(1).Cells(NxtID, "A")
'Look for ID in Column A of Sheet2
With Sheets(2).Range("A1:A" & LastRow)
Set c = .Find(ID, lookat:=xlWhole)
'Delete row in Sheet1 if ID is found on Sheet2
'*** Remove 'Not' to delete rows if ID is not found on Sheet2
If Not c Is Nothing Then Sheets(1).Cells(NxtID, "A").EntireRow.Delete
End With
'Move up 1 row on Sheet1 and check the next ID
Next
End Sub
Reply to spiderind

4


  • This message seems useful, vote!
  • Report this message to moderators
 Temmy, on Wednesday 20 August 2008 à 15:30:39
Hi,
Please can anyone help me here, i want to copy data from another excel workbook and paste as an update into a sheet in a workbook. Manually use 'paste value' to paste into this workbook if its ok to know. How do I write the macro?
Reply to Temmy

2


  • This message seems useful, vote!
  • Report this message to moderators
nijay, on Saturday 28 June 2008 à 12:36:26
Dear sir,


I Want macro commands.I have one dout.one macro program is assembled for 34 sheets.but now i want only 10 sheet how can i change?
Reply to nijay

3


  • This message seems useful, vote!
  • Report this message to moderators
mac, on Monday 7 July 2008 à 16:23:40
Hi

I have an excel worksheet 17165 rows long and column B is 'Years'. B2 is where the spreadsheet starts and is 2006; the years then after repeat in the following order:

B2 2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2006 Here the cycle repeates starting at 2006 again.
2007
2008
2009

I need to add 11 rows below each 2009 for a total of 12 2009 (1 for each month). But only for the year 2009
What I need to do is write a code so that the macro runs trhough all 17165 rows and if it sees 2010 in column B it will add 11 blank rows above it. I am not familiar with excel programming. If possible please write a code for this and send it to me.

Thanks
Reply to mac

Résultats pour Excel: Macro Help

Excel Macro Help Please (Solved) Hello Everyone, I am sking for some help with an Excel macro please. I have a 1,900 hundred static HTML pages that I have converted to text for the purpose of importing to a DB via an Excel CSV file. I have everything sitting in an excel file now with... en.kioskea.net/forum/affich-11146-excel-macro-help-please
Excel Macro for deleting rows IF cells not... Hello, I need help to create a Excel macro. Basicly what I have is a sheet full with information about different departments and what I want to do is delete every row EXCEPT the rows that contain some specified values (wich i would like to enter on... en.kioskea.net/forum/affich-12620-excel-macro-for-deleting-rows-if-cells-not
Excel Macro Help please I need help with an excel macro that will take a username (string) in the first column and look at everytime that they either have an P (present), T (tardy), E (Excused), or A (absent) in a second column. They will be given 400 points if they were... en.kioskea.net/forum/affich-33502-excel-macro-help-please

Résultats pour Excel: Macro Help

To insert an image in the FAQTo insert an image in the FAQ Method Where to find images? Inserting screenshots can help to understand an explanation. Here is how to improve tips on Kioskea (FAQ). For this trick, we opted to use the site Imageshack.us. Note:... en.kioskea.net/faq/sujet-67-to-insert-an-image-in-the-faq
How to open/read a .RBS file!How to open/read a .RBS file! RBS is a file extension describing Rebirth files Song files. It is a common error associated with many file extension errors. This method allows skip over programs that are not recognized and continue process. If... en.kioskea.net/faq/sujet-379-how-to-open-read-a-rbs-file

Résultats pour Excel: Macro Help

Excel MacroI need help with an excel macro that will take a username (string) in the first column and look at everytime that they either have an P (present), T (tardy), E (Excused), or A (absent) in a second column. They will be given 400 points if they were... en.kioskea.net/forum/affich-33540-excel-macro
Excel Macro Help neededI need help with an excel macro that will take a username (string) in the first column and look at everytime that they either have an P (present), T (tardy), E (Excused), or A (absent) in a second column. They will be given 400 points if they were... en.kioskea.net/forum/affich-33099-excel-macro-help-needed
Error In ExcelHello, I recently wrote a fairly complex Excel Macro and have been trying just to work some of the bugs out of it for the past couple weeks. The most recent problems that i've run into is that when it is loaded on to the computer for a while it... en.kioskea.net/forum/affich-20216-error-in-excel

Résultats pour Excel: Macro Help

Spreadsheets - The Excel Interface Microsoft Excel is the spreadsheet in the Microsoft Office office suite. To start it, simply click on the appropriate icon in the Start menu (in Windows) or click on an Excel file (that has an .xls file extension). A Excel document is called a file... en.kioskea.net/tableur/tabinterface.php3
Email - Rules for proper email use Netiquette (a contraction of the words "Net" and "etiquette") refers to the set of rules governing correct behaviour on the Internet, in order to respect others and be respected in turn. They serve as guidelines for civility and proper conduct, so... en.kioskea.net/courrier-electronique/regles-bon-usage-messagerie.php3
Spreadsheets - Cell Selection Spreadsheets are powerful tools for working with data. However, to work with data, it is necessary to have tools to rapidly choose the required cells. An entire line can be chosen by clicking directly on the line header: It is also possible to choose... en.kioskea.net/tableur/tabcellselect-1.php3