VBA CODE REQUIRED

ShoaibAli

Banned - Rules violations
Joined
Jan 15, 2020
Messages
121
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Platform
  1. Windows
Dear Experts,
Here is the Attached file and i have create some Code to do this which is incomplete Please made required changes and update the code according to requirements.

Sheet 1 has Data and Sheet2 has result


VBA Code:
Sub MyVBACODE()
Dim i As Integer
Range("A:A,G:G,I:AG,AI:AZ").EntireColumn.Delete
Columns("A:A").Insert Shift:=xlToRight
For i = 2 To 10000
Cells(i, 1).Value = Cells(i, 4) & ", " & Cells(i, 2) & " " & Cells(i, 3)
Next i
Range("B:D").EntireColumn.Delete
Columns("A:G").Insert Shift:=xlToRight
Range("L:L").Cut Range("A:A")
Range("K:K").Cut Range("D:D")
Range("H:H").Cut Range("E:E")
Range("J:J").Cut Range("F:F")
Range("i:I").Cut Range("G:G")
worksheet.range("
End Sub

1584465767126.png




1584465803252.png



 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Can you please explain, in words, what you need to do.
 
Upvote 0
Hi Fluff,

First attached picture has data and second picture has result. I want proper VBA code i have made a code but it is not proper.
 
Upvote 0
I am not going to try & guess what you want.
Please describe in words what you need.
 
Upvote 0
First attached picture has Data on which i have to apply VBA CODE.

I would like to have Column B,C,D,E,F,H,AH all other columns would be deleted

Column(AH) would be adjust as first Column(A)
Column(H) would be adjust as Column(D)
Column(B,C,D) would be adjust as Column(E) with combine name formula as can seen in VBA COde
Column(F) would be adjust as Column(F)

and have to add "AGE" from DOB and DATE, which would adjust in Column(G)

Sex will be add in last column =if(Male="Male","M","F")
 
Upvote 0
My best guess give or take the age calc....

VBA Code:
Sub MyVBACODE2()
Application.ScreenUpdating = False
Dim i As Integer
Range("G:G,I:AG,AI:AZ").EntireColumn.Delete
Columns("A:A").Insert Shift:=xlToRight
LastRow = Range("C" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Cells(i, 5).Value = Trim(Cells(i, 5) & ", " & Cells(i, 3) & " " & Cells(i, 4))
Next i

Range("I:I").Cut Range("A:A")
Range("B:C").ClearContents
Range("H:H").Cut Range("D:D")
Range("F:F").Cut Range("J:J")
Range("F:F").EntireColumn.Delete
'***
'Range("G2:G" & LastRow).FormulaR1C1 = "=????"
'***
Range("G1") = "Age"
Columns("A:I").EntireColumn.AutoFit
Range("H:H").EntireColumn.Delete
Application.ScreenUpdating = True
End Sub

Hope that helps.
 
Upvote 0
Please supply the cross post link to the other site where you have asked this question.
 
Upvote 0
Link is in my first comment.
 
Upvote 0
Snakehips

thanks for updating the Code but it is not calculating the age which will be done by calculating the Column(F) and Column(D).

and "Male" , "Female" should be show as "M" , "F".
 
Upvote 0

Forum statistics

Threads
1,215,494
Messages
6,125,139
Members
449,207
Latest member
VictorSiwiide

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top