Hi ,
I have attached a file, basically i want to present the data provided in base sheet tab in the format presented in result tab. Can anyone suggest me a way out.
I need to keep only values (after removing all blank and zero values) for each column.
Regards
Shreeram
Changing format of data
-
- 2StarLounger
- Posts: 181
- Joined: 19 Feb 2016, 16:54
- Location: Veraval, India
Changing format of data
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78415
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Changing format of data
Here is a macro:
Code: Select all
Sub CombineColumns()
Dim wshBase As Worksheet
Dim wshResult As Worksheet
Dim col As Long
Dim rng As Range
Dim r As Long
Dim Letter As String
Application.ScreenUpdating = False
Set wshBase = Worksheets("Base sheet")
Set wshResult = Worksheets.Add(After:=wshBase)
wshResult.Range("A1:C1").Value = Array("Letter", "Code", "Amount")
r = 1
For col = 2 To 5
Letter = wshBase.Cells(1, col).Value
With wshBase.Columns(col)
Set rng = .Find(What:="*", After:=wshBase.Cells(1, col))
If Not rng Is Nothing Then
Do
If rng.Value <> 0 Then
r = r + 1
wshResult.Cells(r, 1).Resize(1, 3).Value = Array(Letter, wshBase.Cells(rng.Row, 1).Value, rng.Value)
End If
Set rng = .FindNext(After:=rng)
If rng Is Nothing Then Exit Do
Loop Until rng.Row = 1
End If
End With
Next col
Application.ScreenUpdating = True
End Sub
Best wishes,
Hans
Hans
-
- 2StarLounger
- Posts: 181
- Joined: 19 Feb 2016, 16:54
- Location: Veraval, India
Re: Changing format of data
Thanks Hans, this is very helpful and saves lots of efforts.
-
- 2StarLounger
- Posts: 144
- Joined: 11 Jun 2012, 20:37
Re: Changing format of data
Power Query in attached.
Right-click the table at cell E3 of the Results tab of the attached and choose Refresh (after deleting some of the data in that table or after changing the table on the Base sheet (by changing the data and/or changing the extent of the table).
Right-click the table at cell E3 of the Results tab of the attached and choose Refresh (after deleting some of the data in that table or after changing the table on the Base sheet (by changing the data and/or changing the extent of the table).
You do not have the required permissions to view the files attached to this post.