Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put data from various cells to one cell

Hi all, I am looking for macro which can put data from various cells
to one cell. I have data in my sheet like this (see below)

A B C
…….columns
B1 XX1 REALLOC WB ST …data in 3
cells
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

And I want macro to put data in sheet like this (see below)

A …….column
B1 XX1 REALLOC WB ST ….data in one
cell
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. I have tried doing it by " A1&" "&B1&" "&Cl " but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. I hope i was able to
explain my question. Please can any friend help me on this
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Put data from various cells to one cell

Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range

With ActiveSheet

On Error Resume Next
Set rngSource = Application.InputBox("Select source range", Type:=8)
On Error GoTo 0
If rngSource Is Nothing Then Exit Sub

On Error Resume Next
Set rngTarget = Application.InputBox("Select target cell", Type:=8)
On Error GoTo 0
If rngTarget Is Nothing Then Exit Sub

rngSource.Copy rngTarget
With rngSource

For i = 1 To .Rows.Count - 1

LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
..Cells(1, 1).Column + 1
For j = LastCol - 1 To 3 Step -1

rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
rngTarget.Cells(i, j +
1).Value
rngTarget.Cells(i, j + 1).Value = ""
Next j
Next i
End With
End With

End Sub



--
__________________________________
HTH

Bob

"K" wrote in message
...
Hi all, I am looking for macro which can put data from various cells
to one cell. I have data in my sheet like this (see below)

A B C
…….columns
B1 XX1 REALLOC WB ST …data in 3
cells
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

And I want macro to put data in sheet like this (see below)

A …….column
B1 XX1 REALLOC WB ST ….data in one
cell
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. I have tried doing it by " A1&" "&B1&" "&Cl " but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. I hope i was able to
explain my question. Please can any friend help me on this


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put data from various cells to one cell

On Sep 11, 12:27*pm, "Bob Phillips" wrote:
Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range

* * With ActiveSheet

* * * * On Error Resume Next
* * * * Set rngSource = Application.InputBox("Select source range", Type:=8)
* * * * On Error GoTo 0
* * * * If rngSource Is Nothing Then Exit Sub

* * * * On Error Resume Next
* * * * Set rngTarget = Application.InputBox("Select target cell", Type:=8)
* * * * On Error GoTo 0
* * * * If rngTarget Is Nothing Then Exit Sub

* * * * rngSource.Copy rngTarget
* * * * With rngSource

* * * * * * For i = 1 To .Rows.Count - 1

* * * * * * * * LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
.Cells(1, 1).Column + 1
* * * * * * * * For j = LastCol - 1 To 3 Step -1

* * * * * * * * * * rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
* * * * * * * * * * * * * * * * * * * * * * * *rngTarget.Cells(i, j +
1).Value
* * * * * * * * * * rngTarget.Cells(i, j + 1).Value = ""
* * * * * * * * Next j
* * * * * * Next i
* * * * End With
* * End With

End Sub

--
__________________________________
HTH

Bob

"K" wrote in message

...
Hi all, I am looking for macro which can put data from various cells
to one cell. *I have data in my sheet like this (see below)

* * * *A * * * * * * * *B * * * * * * * * * * * *C
…….columns
* * *B1 * * * * * * XX1 * * * * * REALLOC WB ST *…data in 3
cells
* * *C20 * * * * * XX12 * * * * TRANSFERRED DD
* * *UK5 * * * * * XX123 * * * REALLOC WB DE
* * *K56 * * * * * XX * * * * * * UPDATED XX36
* * *ZA8 * * * * * XX12 * * * * FIGUERS NY

And I want macro to put data in sheet like this (see below)

* * * *A * …….column
* * *B1 * * * * * * XX1 * * * * * REALLOC WB ST ….data in one
cell
* * *C20 * * * * * XX12 * * * * TRANSFERRED DD
* * *UK5 * * * * * XX123 * * * REALLOC WB DE
* * *K56 * * * * * XX * * * * * * UPDATED XX36
* * *ZA8 * * * * * XX12 * * * * FIGUERS NY

It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. *I have tried *doing it by " *A1&" * *"&B1&" * * "&Cl *" but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. * macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. *I hope i was able to
explain my question. *Please can any friend *help me on this


Thanks for reply Bob. i am getting error on line LastCol
= .Cells(i, .Columns.Count).End(xlUp).Column -
..Cells(1, 1).Column + 1
when i paste your code into module. Any idea what i am doing wrong?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put data from various cells to one cell

On Sep 11, 12:27*pm, "Bob Phillips" wrote:
Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range

* * With ActiveSheet

* * * * On Error Resume Next
* * * * Set rngSource = Application.InputBox("Select source range", Type:=8)
* * * * On Error GoTo 0
* * * * If rngSource Is Nothing Then Exit Sub

* * * * On Error Resume Next
* * * * Set rngTarget = Application.InputBox("Select target cell", Type:=8)
* * * * On Error GoTo 0
* * * * If rngTarget Is Nothing Then Exit Sub

* * * * rngSource.Copy rngTarget
* * * * With rngSource

* * * * * * For i = 1 To .Rows.Count - 1

* * * * * * * * LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
.Cells(1, 1).Column + 1
* * * * * * * * For j = LastCol - 1 To 3 Step -1

* * * * * * * * * * rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
* * * * * * * * * * * * * * * * * * * * * * * *rngTarget.Cells(i, j +
1).Value
* * * * * * * * * * rngTarget.Cells(i, j + 1).Value = ""
* * * * * * * * Next j
* * * * * * Next i
* * * * End With
* * End With

End Sub

--
__________________________________
HTH

Bob

"K" wrote in message

...
Hi all, I am looking for macro which can put data from various cells
to one cell. *I have data in my sheet like this (see below)

* * * *A * * * * * * * *B * * * * * * * * * * * *C
…….columns
* * *B1 * * * * * * XX1 * * * * * REALLOC WB ST *…data in 3
cells
* * *C20 * * * * * XX12 * * * * TRANSFERRED DD
* * *UK5 * * * * * XX123 * * * REALLOC WB DE
* * *K56 * * * * * XX * * * * * * UPDATED XX36
* * *ZA8 * * * * * XX12 * * * * FIGUERS NY

And I want macro to put data in sheet like this (see below)

* * * *A * …….column
* * *B1 * * * * * * XX1 * * * * * REALLOC WB ST ….data in one
cell
* * *C20 * * * * * XX12 * * * * TRANSFERRED DD
* * *UK5 * * * * * XX123 * * * REALLOC WB DE
* * *K56 * * * * * XX * * * * * * UPDATED XX36
* * *ZA8 * * * * * XX12 * * * * FIGUERS NY

It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. *I have tried *doing it by " *A1&" * *"&B1&" * * "&Cl *" but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. * macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. *I hope i was able to
explain my question. *Please can any friend *help me on this


Hi Bob, its ok now i fixed that thing . i did try your code but its
not putting various cells data into one cell. what it does is take
data from source range and then put it in same way in destination
range but not in one cell. any idea how this can be resolved
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Put data from various cells to one cell

It does in my tests. First it copies the data across wholesale, then it
merges columns 3 on.

--
__________________________________
HTH

Bob

"K" wrote in message
...
On Sep 11, 12:27 pm, "Bob Phillips" wrote:
Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range

With ActiveSheet

On Error Resume Next
Set rngSource = Application.InputBox("Select source range", Type:=8)
On Error GoTo 0
If rngSource Is Nothing Then Exit Sub

On Error Resume Next
Set rngTarget = Application.InputBox("Select target cell", Type:=8)
On Error GoTo 0
If rngTarget Is Nothing Then Exit Sub

rngSource.Copy rngTarget
With rngSource

For i = 1 To .Rows.Count - 1

LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
.Cells(1, 1).Column + 1
For j = LastCol - 1 To 3 Step -1

rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
rngTarget.Cells(i, j +
1).Value
rngTarget.Cells(i, j + 1).Value = ""
Next j
Next i
End With
End With

End Sub

--
__________________________________
HTH

Bob

"K" wrote in message

...
Hi all, I am looking for macro which can put data from various cells
to one cell. I have data in my sheet like this (see below)

A B C
…….columns
B1 XX1 REALLOC WB ST …data in 3
cells
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

And I want macro to put data in sheet like this (see below)

A …….column
B1 XX1 REALLOC WB ST ….data in one
cell
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY

It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. I have tried doing it by " A1&" "&B1&" "&Cl " but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. I hope i was able to
explain my question. Please can any friend help me on this


Hi Bob, its ok now i fixed that thing . i did try your code but its
not putting various cells data into one cell. what it does is take
data from source range and then put it in same way in destination
range but not in one cell. any idea how this can be resolved




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Put data from various cells to one cell

On Sep 11, 1:06*pm, "Bob Phillips" wrote:
It does in my tests. First it copies the data across wholesale, then it
merges columns 3 on.

--
__________________________________
HTH

Bob

"K" wrote in message

...
On Sep 11, 12:27 pm, "Bob Phillips" wrote:





Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range


With ActiveSheet


On Error Resume Next
Set rngSource = Application.InputBox("Select source range", Type:=8)
On Error GoTo 0
If rngSource Is Nothing Then Exit Sub


On Error Resume Next
Set rngTarget = Application.InputBox("Select target cell", Type:=8)
On Error GoTo 0
If rngTarget Is Nothing Then Exit Sub


rngSource.Copy rngTarget
With rngSource


For i = 1 To .Rows.Count - 1


LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
.Cells(1, 1).Column + 1
For j = LastCol - 1 To 3 Step -1


rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
rngTarget.Cells(i, j +
1).Value
rngTarget.Cells(i, j + 1).Value = ""
Next j
Next i
End With
End With


End Sub


--
__________________________________
HTH


Bob


"K" wrote in message


...
Hi all, I am looking for macro which can put data from various cells
to one cell. I have data in my sheet like this (see below)


A B C
…….columns
B1 XX1 REALLOC WB ST …data in 3
cells
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY


And I want macro to put data in sheet like this (see below)


A …….column
B1 XX1 REALLOC WB ST ….data in one
cell
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY


It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. I have tried doing it by " A1&" "&B1&" "&Cl " but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. I hope i was able to
explain my question. Please can any friend help me on this


Hi Bob, its ok now i fixed that thing . *i did try your code but its
not putting various cells data into one cell. *what it does is take
data from source range and then put it in same way in destination
range but not in one cell. any idea how this can be resolved- Hide quoted text -

- Show quoted text -


I think you misunderstood my question. I don't want data to be merged
from column 3 on. I want data of 3 columns cells to appear in 1
column cell. Its ok I might come again with more clear explaination I
think its my faul that I wasn't able to explain what i want. Thanks
any way Bob for you time.
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Put data from various cells to one cell

That is what merge columns 3 on means.

--
__________________________________
HTH

Bob

"K" wrote in message
...
On Sep 11, 1:06 pm, "Bob Phillips" wrote:
It does in my tests. First it copies the data across wholesale, then it
merges columns 3 on.

--
__________________________________
HTH

Bob

"K" wrote in message

...
On Sep 11, 12:27 pm, "Bob Phillips" wrote:





Public Sub ProcessData()
Dim i As Long, j As Long
Dim LastCol As Long
Dim rngTarget As Range
Dim rngSource As Range


With ActiveSheet


On Error Resume Next
Set rngSource = Application.InputBox("Select source range", Type:=8)
On Error GoTo 0
If rngSource Is Nothing Then Exit Sub


On Error Resume Next
Set rngTarget = Application.InputBox("Select target cell", Type:=8)
On Error GoTo 0
If rngTarget Is Nothing Then Exit Sub


rngSource.Copy rngTarget
With rngSource


For i = 1 To .Rows.Count - 1


LastCol = .Cells(i, .Columns.Count).End(xlUp).Column -
.Cells(1, 1).Column + 1
For j = LastCol - 1 To 3 Step -1


rngTarget.Cells(i, j).Value = rngTarget.Cells(i,
j).Value & " " & _
rngTarget.Cells(i, j +
1).Value
rngTarget.Cells(i, j + 1).Value = ""
Next j
Next i
End With
End With


End Sub


--
__________________________________
HTH


Bob


"K" wrote in message


...
Hi all, I am looking for macro which can put data from various cells
to one cell. I have data in my sheet like this (see below)


A B C
…….columns
B1 XX1 REALLOC WB ST …data in 3
cells
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY


And I want macro to put data in sheet like this (see below)


A …….column
B1 XX1 REALLOC WB ST ….data in one
cell
C20 XX12 TRANSFERRED DD
UK5 XX123 REALLOC WB DE
K56 XX UPDATED XX36
ZA8 XX12 FIGUERS NY


It would be very nice that when I click button then macro should
prompt Inputbox saying select the range of data cells and when I press
"OK" it should promt another Inputbox saying select destination cell
for data and then by clicking on "OK" it should put data in that
cell. I have tried doing it by " A1&" "&B1&" "&Cl " but i
dont get exact picture what it appears on sheet and i endup putting
spaces manully between the data to make them look in cell exactly the
way it look when it is in various cells. macro should atumatically
put spaces between data and make them exactly accurate horizontically
and vertically the way it look in variuos cells. I hope i was able to
explain my question. Please can any friend help me on this


Hi Bob, its ok now i fixed that thing . i did try your code but its
not putting various cells data into one cell. what it does is take
data from source range and then put it in same way in destination
range but not in one cell. any idea how this can be resolved- Hide quoted
text -

- Show quoted text -


I think you misunderstood my question. I don't want data to be merged
from column 3 on. I want data of 3 columns cells to appear in 1
column cell. Its ok I might come again with more clear explaination I
think its my faul that I wasn't able to explain what i want. Thanks
any way Bob for you time.


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
compare 2 column cells and return the adjacent columns cells data of the cell trebor57 Excel Worksheet Functions 1 February 1st 11 02:54 PM
if 3 cells have data then add certain value to another cell Gerigto Excel Worksheet Functions 2 March 28th 07 02:51 AM
if 3 cells have data then add certain value to another cell Mike Excel Worksheet Functions 0 March 28th 07 01:16 AM
Send multi data (Graph/Cell data) to Word doc as 1 item (no cells) Tom-LE Excel Discussion (Misc queries) 0 August 30th 06 10:10 PM
Cell data overruns into adjacent cell(cells). Art Excel Discussion (Misc queries) 1 June 24th 05 06:46 PM


All times are GMT +1. The time now is 07:45 AM.

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"