Need help in Excel Macro
Solved/Closed
zeromaim
Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008
-
Jul 29, 2008 at 10:46 AM
Jnani - Mar 20, 2009 at 11:38 PM
Jnani - Mar 20, 2009 at 11:38 PM
Related:
- Need help in Excel Macro
- Spell number in excel without macro - Guide
- Macros in excel download - Download - Spreadsheets
- Marksheet in excel - Guide
- How to take screenshot in excel - Guide
- Gif in excel - Guide
5 responses
Ivan-hoe
Posts
433
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008
110
Aug 5, 2008 at 06:32 PM
Aug 5, 2008 at 06:32 PM
Hello Zero,
in the macro below, the loop For Each Mycell ... Next Mycell "reads" the contents of each cell in the given range (G11:G23) of the first table.
Whatever the ID is, the same operations are completed : insert a row and copy out data from the first table into the second one ; this is done in the bundle With Marker .... End With .
Only the initial cell changes. Thus the idea is to start the copy from a cell (named Marker) that depends on the ID ; this is done with Select Case ... End Select
Ivan
in the macro below, the loop For Each Mycell ... Next Mycell "reads" the contents of each cell in the given range (G11:G23) of the first table.
Whatever the ID is, the same operations are completed : insert a row and copy out data from the first table into the second one ; this is done in the bundle With Marker .... End With .
Only the initial cell changes. Thus the idea is to start the copy from a cell (named Marker) that depends on the ID ; this is done with Select Case ... End Select
Ivan
Sub Zeromaim() Dim MyCell As Range, Marker As Range Dim LowerBoundaryForA As Range, LowerBoundaryForB As Range, LowerBoundaryForC As Range With Sheets("Sheet2") Set LowerBoundaryForA = .Range("K12") Set LowerBoundaryForB = .Range("K14") Set LowerBoundaryForC = .Range("K16") End With Sheets("Sheet1").Activate For Each MyCell In Range("G11:G23") Select Case UCase(MyCell.Value) Case Is = "A" Set Marker = LowerBoundaryForA Case Is = "B" Set Marker = LowerBoundaryForB Case Is = "C" Set Marker = LowerBoundaryForC End Select With Marker .EntireRow.Insert .Offset(-1, 0).Value = MyCell.Offset(0, -1).Value .Offset(-1, 1).Value = MyCell.Offset(0, 1).Value .Offset(-1, 2).Value = MyCell.Offset(0, 2).Value End With Next MyCell End Sub
Ivan-hoe
Posts
433
Registration date
Saturday February 16, 2008
Status
Member
Last seen
October 17, 2008
110
Aug 7, 2008 at 04:23 AM
Aug 7, 2008 at 04:23 AM
Sub Zeromaim() Dim MyCell As Range, Marker As Range Dim LowerBoundaryForA As Range, LowerBoundaryForB As Range, LowerBoundaryForC As Range With Sheets("Sheet2") Set LowerBoundaryForA = .Range("K12") Set LowerBoundaryForB = .Range("K14") Set LowerBoundaryForC = .Range("K16") End With Sheets("Sheet1").Activate For Each MyCell In Range("G11:G23") Stop Select Case UCase(MyCell.Value) Case Is = "A" Set Marker = LowerBoundaryForA Case Is = "B" Set Marker = LowerBoundaryForB Case Is = "C" Set Marker = LowerBoundaryForC Case Else Set Marker = Nothing End Select If Not Marker Is Nothing Then With Marker .EntireRow.Insert .Offset(-1, 0).Value = MyCell.Offset(0, -1).Value .Offset(-1, 1).Value = MyCell.Offset(0, 1).Value .Offset(-1, 2).Value = MyCell.Offset(0, 2).Value End With End If Next MyCell End Sub
Hi All,
I need to extract mysql database to my spreadsheet.The requirement goes like this ..I have a database table in mysql which I need to extract to my spreadsheet.It should happen while I trigger the Button in the spreadsheet.And It should be compatible to all the cell operations. Thanks in advance for the valuable suggestions which I may get from you all guys.
Thanks and regards
Jnani
I need to extract mysql database to my spreadsheet.The requirement goes like this ..I have a database table in mysql which I need to extract to my spreadsheet.It should happen while I trigger the Button in the spreadsheet.And It should be compatible to all the cell operations. Thanks in advance for the valuable suggestions which I may get from you all guys.
Thanks and regards
Jnani
zeromaim
Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008
Aug 6, 2008 at 08:46 AM
Aug 6, 2008 at 08:46 AM
Thanks Ivan,
Follow up question :)
Kindly insert a code that if the ID is anything other than A, B, and C, the program will just skip to evaluate the next row (no inserting). If column G11:G23 reads as A, B, C, D, E, A, B, C, etc..., the program should not copy-insert the row associated to ID D, E, and other IDs.
Thanks again and hope to hear from you soon.
Anton
Follow up question :)
Kindly insert a code that if the ID is anything other than A, B, and C, the program will just skip to evaluate the next row (no inserting). If column G11:G23 reads as A, B, C, D, E, A, B, C, etc..., the program should not copy-insert the row associated to ID D, E, and other IDs.
Thanks again and hope to hear from you soon.
Anton
Didn't find the answer you are looking for?
Ask a question
zeromaim
Posts
10
Registration date
Monday July 28, 2008
Status
Member
Last seen
August 8, 2008
Aug 8, 2008 at 07:29 AM
Aug 8, 2008 at 07:29 AM
Hi Ivan,
Thanks again, it's perfect.
How do I change the status of this topic to resolve? Anyone?
Anton
Thanks again, it's perfect.
How do I change the status of this topic to resolve? Anyone?
Anton
Aug 6, 2008 at 08:42 AM
Thanks again for the reply, the code was very helpful. I have some follow up question, kindly refer to the post "Need help in Excel Macro" posted by zeromaim.
Kindly insert a code that if the ID is anything other than A, B, and C, the program will just skip to evaluate the next row (no inserting). If column G11:G23 reads as A, B, C, D, E, A, B, C, etc..., the program should not copy-insert the row associated to ID D, E, and other IDs.
Thanks again and hope to hear from you soon.
Anton